Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2005

Tip: Looking for answers? Try searching our database.

Dll pb

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NewsUser - 17 Dec 2005 11:08 GMT
Hi all,
First Excuse my poor english
Here is the code :
********************************************
Option Compare Database
Option Explicit
Declare Function ExportSessionFromSTZ Lib "c:\tafia\STZExport.dll" ()

Sub Test()
Dim x
x = ExportSessionFromSTZ("P1", "P2", "P3")
End Sub
*********************************************
STZExport.dll is an externe STDcall Delphi DLL store in the same directory
than the MDB file (c:\tafia)

This dll include only one function with 3 strings parameters.

Compil is ok but when i execute Test a error message tell me : "Cannot find
c:\tafia\STZExport.dll"

When i try to register the Dll with this cmdline : regsvr32
"c:\tafia\STZExport.dll" i have also an error message say "cannot find the
Module".

anyone have an idee ?
Thank by advance,
@+
Alex Dybenko - 17 Dec 2005 19:53 GMT
hi,
perhaps you need to load it:

Private Declare Function GetModuleHandle Lib "kernel32" Alias
"GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA"
(ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As
Long, ByVal lpProcName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As
Long) As Long

   Dim hModule As Long
   Dim lpProc As Long
   Dim FreeLib As Boolean, FreeLib2 As Boolean
   Dim ret As Integer
   Dim strDllPath As String
   strDllPath = "C:\mypath\"

  ' check first to see if the module is already
  ' mapped into this process.
  hModule = GetModuleHandle(strDllPath & "my.dll")
  If hModule = 0 Then
     ' need to load module into this process.
     hModule = LoadLibrary(strDllPath & "my.dll")
     FreeLib = True
  End If

  Dim returnVal
  ' if the module is mapped, check procedure
  ' address to verify it's exported.
  If hModule Then
     lpProc = GetProcAddress(hModule, "ExportSessionFromSTZ")
     If lpProc <> 0 Then
       x = ExportSessionFromSTZ("P1", "P2", "P3")
     End If
  End If
  If FreeLib Then Call FreeLibrary(hModule)

HTH
Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Hi all,
> First Excuse my poor english
[quoted text clipped - 24 lines]
> Thank by advance,
> @+
NewsUser - 18 Dec 2005 08:25 GMT
Thanks a lot,
I'm going to traing this immediatly.
Didier

> hi,
> perhaps you need to load it:
[quoted text clipped - 64 lines]
>> Thank by advance,
>> @+
NewsUser - 18 Dec 2005 08:43 GMT
sorry, That dont woks,
>   ' check first to see if the module is already
>   ' mapped into this process.
[quoted text clipped - 4 lines]
>      FreeLib = True
>   End If

At this point hModule stay to 0
But i think the Dll need a missing library.  I'am waiting an answer from his
developer.
Thank,
Didier,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.