Allow us to get the address of API functions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Allow us to get the address of API functions

Post 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.
Opcode
Enthusiast
Enthusiast
Posts: 137
Joined: Thu Jul 18, 2013 4:58 am

Re: Allow us to get the address of API functions

Post 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
Post Reply