In assembly, we do things by calling the functions of the operating system. In dos it's a combonation of setting up what function you want to use, and then calling the appropriate interrupt. In windows we push the paramameters onto the stack, then call a function defined in a dynamically linked library, after you've told the compiler what dll you're using, and how the function gets used (the prototype). BUT - how do people using High Level languages do this? They usually don't use the API from what little I know. Or at least when then begin writing code. Do those librarys they include make use of the API, and then just give them an easier function name to use (exit() or whatever)? And when they make console applications do the High Level compilers use dos functions or still use the API?? (BTW what is api an acronym for?) Thanks to anybody that can help me, it isn't a big problem or anything. But I do think it would be interesting to know, and potentially useful. @ Matt, the curious.
Posted on 2001-05-06 14:41:00 by matthew
I can only say something about Delphi as I don't have any other languages of this format at hand. In Delphi you too use the APIs like in MASM but you don't INVOKE them but simply call them and the compiler does the job for you. There you can just use

MessageBox(NULL,'Something','Something different',MB_OK);
and this does the same as

invoke MessageBox,NULL,addr Text,addr Caption,MB_OK
I can't tell you about the way the compiler exactly works though but they use the APIs. Of course they have other functions too defined in the Components which make it easier for the programmer to use APIs. So, instead of the MessageBox you can use

ShowDialog('I can see this' + #0D + #0A + 'and this in different rows!'); 
(or is it ShowMessage? Dunno, I am not using Delphi)
Maybe is answers your question at least a bit. Stefan This message was edited by Stefan Krause, on 5/6/2001 3:11:50 PM
Posted on 2001-05-06 15:08:00 by Stefan Krause
I think that at the end it all comes down to API functions as that's the way Windows works. Windows provides the functions and each program that should run on Windows should use these functions. High level languages most of the time have some additional library (which is then linked statically or used as .dll), that contains basic functions but they are just an extra layer on the windows API. Console applications don't use DOS functions as they are windows applications. The only difference with normal programs is that they run in a console. But dos functions are not used. API stands for Application Programming Interface. Thomas
Posted on 2001-05-06 15:11:00 by Thomas
Stefan, you're fast this time. see! we all have chances. ehheh
Hehe, yes but it was very short this time. I had written the text and sent it away and no others were there and than I saw that I had to revise one thing and after update you all were there. Phew, am I lucky! Stefan
Posted on 2001-05-06 15:15:00 by Stefan Krause
VFP (Visual FoxPro) has wrappers around some APIfunctions, so we don't even know that we are using a function in an api external to VFP. For commands that aren't supported natively. FoxPro is an interpreted language.


DECLARE
Registers a function in an external shared library. Libraries are 32-bit dynamic link library (.DLL) files.

Syntax

DECLARE  FunctionName IN LibraryName 
	 ParamName1,
 	cParamType2 [@] ParamName2, ...]


---Example 1---

DECLARE INTEGER GetActiveWindow IN win32api
? GetActiveWindow( )

--End Example 1---

* The ? prints to the main VFP screen the result of the function
* asterisk is used for comments in VFP when it is the first non-whitespace 
* character, otherwise multiply
&& double ampersand denotes a comment after a command
 

---Example 2 ---

This example illustrates calling the Windows API function GetSystemTime. GetSystemTime
fills in a structure of WORD (16-bit unsigned integer) values with system time information. 

C Function Declaration and Struct Definition

VOID GetSystemTime(
    LPSYSTEMTIME lpSystemTime 	// address of system time structure  
   );	

This is the struct definition

typedef struct _SYSTEMTIME {
    WORD wYear; 
    WORD wMonth; 
    WORD wDayOfWeek; 
    WORD wDay; 
    WORD wHour; 
    WORD wMinute; 
    WORD wSecond; 
    WORD wMilliseconds; 
} SYSTEMTIME; 

*---Begin FoxPro---
* Calling the Function in Visual FoxPro

* The Visual FoxPro code passes GetSystemTime a reference to a character variable, 
* which is filled in with the WORD values. 

DECLARE INTEGER GetSystemTime IN win32api STRING @
cBuff=SPACE(40)

GetSystemTime(@cBuff)

* To retrieve the information from the character variable, cBuff, the following code 
* converts 8 bit ASCII characters for year and month in the variable into 16 bit equivalents.

THIS.Parent.lblYear.Caption = ALLTRIM(STR(ASC(SUBSTR(cBuff,2)) * 256 + ASC(SUBSTR(cBuff,1))))

THIS.Parent.lblMonth.Caption = MONTH_LOC + ALLTRIM(STR(ASC(SUBSTR(cBuff,4)) * 256 + ASC(SUBSTR(cBuff,3))))

* Note THIS.Parent refers to the Window, Class or Control used, the rest of the code isn't shown. 
*---End Foxpro code---
Posted on 2001-05-06 16:28:00 by SFinegan
In C you use the same API that you use in asm or any other language. C++ can use also API, and some wrapper->MFC...but it all boil down to the same API. So we all use same sh**. :)
Posted on 2001-05-06 20:15:00 by Geecko
Back to delphi.. =) It's true you can use API's right on with delphi. As a matter of fact, if you want to do advanced programming with delphi it all comes down to APIs. However the included libraries also uses the APIs in one way or another. Tho I've seen functions that use some ASM too, that's the case with the string handling fucntions for example =)) //Phrekie
Posted on 2001-05-09 05:05:00 by Phrekie
Some system tasks (e.g., file I/O) are implemented across all OS's either with a standard subroutine call (a la C/C++) or through standard commands (a la older languages such as Fortran, Basic, Cobol). The commands or subroutines hide the actual calls to the OS. Some language systems (compilers or environments) provide ways to directly access the local OS services. But if the language allows you to link to other modules, you can always create wrapper subroutines for any OS service.
Posted on 2001-05-11 15:01:00 by tank