API Calls

BlitzMax Forums/BlitzMax Programming/API Calls

William Drescher(Posted 2008) [#1]
Could anyone please tell me how to do API calls from user32 and kernel32?


Azathoth(Posted 2008) [#2]
Like this
Extern "Win32"
	Function GetCurrentProcess:Int()
	Function ReadProcessMemory:Int(hProcess:Int,lpBaseAddress:Byte Ptr,lpBuffer:Byte Ptr,nSize:Int,lpNumberOfBytesRead:Byte Ptr)
	Function WriteProcessMemory:Int(hProcess:Int,lpBaseAddress:Byte Ptr,lpBuffer:Byte Ptr,nSize:Int,lpNumberOfBytesWritten:Byte Ptr)
EndExtern



William Drescher(Posted 2008) [#3]
Does using "Win32" as the head open user32.dll,kernel32.dll, and gdi32.dll?


Dreamora(Posted 2008) [#4]
it will link it against the own kernel32.a etc in the lib folder. with 1.26+ and mingw 5.1 this should cover more or less all XP API capabilities, yes.


Azathoth(Posted 2008) [#5]
"Win32" is the stdcall calling convention, your source code gets linked with user32 and kernel32 anyway.
If you want to link an import library in the lib folder use "import -l" followed by the name. If you rather load a dll at run-time use the GetProcAddress API.