Dll pb

N

NewsUser

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,
@+
 
A

Alex Dybenko

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
 
N

NewsUser

sorry, That dont woks,
' 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

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top