Page 1 of 1

Allow us to get the address of API functions

Posted: Sat Oct 19, 2019 4:42 am
by Mistrel

Code: Select all

Debug @GetProcAddress_()
Error:
GetProcAddress_() is Not declared.
PureBasic already knows about these functions. It would be nice if I could obtain the address with the "@" operator.

Re: Allow us to get the address of API functions

Posted: Fri Oct 25, 2019 5:07 am
by Opcode
I don't really see the point as calling that particular API function is used for that exact purpose.

Code: Select all

Import "Kernel32.lib"
  GetProcAddress_(hModule.l, lpProcName.p-ascii) As "_GetProcAddress@8"
EndImport

Debug GetProcAddress_(GetModuleHandle_("Kernel32.dll"), "GetProcAddress")
Or you can go the PB route.

Code: Select all

If OpenLibrary(0, "Kernel32.dll")
  
  If ExamineLibraryFunctions(0)
    While NextLibraryFunction()
      If LibraryFunctionName() = "GetProcAddress"
        Debug LibraryFunctionAddress()
        Break
      EndIf
    Wend
  EndIf
  
  CloseLibrary(0)
  
EndIf