Announcement

Collapse
No announcement yet.

Referenceing DLLs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Referenceing DLLs

    How do I reference a windows dll within Powerbasic

  • #2
    Open win32api.inc, identical.

    Declare ... LIB .... etc..
    hellobasic

    Comment


    • #3
      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


      • #4
        Referencing DLLs

        Many Thanks

        Comment

        Working...
        X