gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1565 Posts in 517 Topics by 752 Members - Latest Member: zaikunzhang September 25, 2021, 05:15:23 PM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Windows  |  How to late-load a DLL
gfx
gfxgfx
 

Author Topic: How to late-load a DLL  (Read 5707 times)

Mike Linacre

  • Sr. Member
  • ****
  • Posts: 250
How to late-load a DLL
« on: May 17, 2007, 10:05:51 PM »
This is useful if the DLL may not exist, or may be a different version to the developer's, or may not have the module, ....

C Do this once to get the entry point
       Subroutine GetDLLEntryPoint (YourEntryPoint)
       stdcall external LoadLibraryA, GetProcAddress
       integer*4 LoadLibraryA, GetProcAddress
       integer*4 pl, pm, plvalue, YourEntryPoint
       character*100 LibraryName, ModuleName
       YourEntryPoint=0
       LibraryName = "KERNEL32.DLL"//char(0)
       ModuleName = "SetFilePointerEx"//char(0)
       pl = loc(YourLibraryName)
       plvalue = LoadLibraryA (val(pl))
       if (plvalue.ne.0) then
         pm = loc(YourModuleName)
         YourEntryPoint = GetProcAddress (val(plvalue), val(pm))
       endif
       end 

C Do this each time you need to access the module in the DLL
       if (YourEntryPoint.ne.0) then
         call YourDLLModule (val(YourEntryPoint),val(your parameter 1), val(),...)
       endif

C This does the DLL module access
       SUBROUTINE YourDLLModule (YourEntryPoint, your parameter 1, ...)
       STDCALL EXTERNAL YourEntryPoint
       integer*4 iostat, your parameter 1, ....
       iostat = YourEntryPoint (val(your parameter 1), ....)
       end

Absoft User Forum  |  Support  |  Windows  |  How to late-load a DLL
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!