Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows API - Linking
#1
This question has been bugging me for quite a while.
When writing Windows code, using the Windows API, how do you access the functions? Do you have to link to something? Do you have to declare what functions you use (like QB with libraries, C, and Assembly with libraries)?
And where can you get the libs, if you need them?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#2
You Load DLLs.

And call them. :*)

One is the ever popular User32
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#3
In VB this is handled automaticly. You just use a DECLARE which tells in which DLL the function is:

Code:
Declare Function BitBlt Lib "gdi32.dll" ( _
     ByVal hDestDC As Long, _
     ByVal x As Long, _
     ByVal y As Long, _
     ByVal nWidth As Long, _
     ByVal nHeight As Long, _
     ByVal hSrcDC As Long, _
     ByVal xSrc As Long, _
     ByVal ySrc As Long, _
     ByVal dwRop As Long) As Long

In C or C++ you have small LIBs that are linked with your project that are used to interface with the DLLs. You specify which ones in the project settings dialog of your compiler.

Windows is built using a "micro kernel" architecture, where there is a Kernel which is used to communicate several modules (or servers) that do the file managing, the memory managing, the graphics output and everything (USER32.DLL, GDI32.DLL...). Those LIBs are shared and called by the processes using those Windows API calls.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
Right...same with assembly, right? You link to User32.lib for Window generation, and Kernel32.lib for Windows Console functions?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#5
I think so, but I don't really know 'cause I only know 0.2% of 16 bits DOS assembly Tongue
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
Ah, okay. Now I understand. Smile
I posted something simliar to the following recently, but I didn't understand the answer...let me rephrase my question:
In 16-bit real mode MSDOS assembly, if you execute the following code:
Code:
mov ax,[5F2Ah]
In which segment does it access offset 5F2Ah?
Also, when you have the "data" segment and the "code" segment of a program...does that mean that the data and code segments are loaded in different actual MSDOS segments? Or is the whole program loaded into one segment, then code and data are "subsegments" of that segment?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#7
It looks in the current DATA segment. That is done automaticly by your assembler.

* If you are in tiny model, there is just 1 segment for code, data and stack.

* If you are in medium model (QB, for example) you have just one data segment. Same with the small model.

* In the huge model ... I dunno Tongue maybe where DS points.

The second question: That depends on the memory model. I don't remember those quite well, but I think it was...

* Tiny model: 1 segment for code, data and stack (this is: just 64 Kb for everything)
* Small model: 1 segment for code, 1 segment for data. Dunno where is the stack.
* Medium model: Several segments for code, 1 segment for data.
* Big model: Can't remember if such a model existed.
* Huge model: Several segments for code, several segments for data.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#8
Alrighty. And the data segment is indicated by the address in DS?
And what about my second question, regarding the sub-segment or real-segment inquiry?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#9
:???: I think I replied your two questions... :o
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#10
...About whether an msdos "segment" is different than a "code" or "data" segment...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)