How do I reference a windows dll within Powerbasic
Announcement
Collapse
No announcement yet.
Referenceing DLLs
Collapse
X
-
Ahmad,
Have a look at the win32api.inc file in your \Pbwin\winapi\ directory. Towards the end you'll see all the common Windows API functions already declared for you.
For example:
DECLARE FUNCTION DeleteFile LIB "KERNEL32.DLL" ALIAS "DeleteFileA" (lpFileName AS ASCIIZ) AS LONG
Using it is then as simple as: DeleteFile "c:\tempfile.dat"
Alternatively you can reference it dynamically, for example ...
DECLARE FUNCTION DeleteFile (lpFileName AS ASCIIZ) AS LONG
LOCAL hLib AS DWORD, hProc AS DWORD
hLib = GetModuleHandle("kernel32.dll"): IF hLib = 0 THEN hLib = LoadLibrary("kernel32.dll")
hProc = GetProcAddress(hLib, "DeleteFileA")
CALL DWORD hProc USING DeleteFile("c:\tempfile.dat")-
Comment
Comment