Hi,
I'm still with my problem of string resource to load from a C++ DLL.
Here is my code :
in my module i have the function for loading DLL and sending back a string to main form.
where MyForm is the reference to my main form and MyLanguage is in fact, the file name of my DLL to load...for example "english.dll"
Function ChangeLanguage(ByRef MyForm As FMain, ByVal MyLanguage As String) As Boolean
Dim strFilePath As String
Dim hLibrary As Long
Dim strString As String
Dim lngStringLen As Long
' Get the path to the Resource DLL
strFilePath = System.IO.Directory.GetCurrentDirectory
strFilePath = strFilePath & "\" & MyLanguage
' Load the Resource DLL
hLibrary = FMain.LoadLibrary(strFilePath)
If hLibrary = 0 Then
MsgBox("Failed to load the specified library with error code " & Err.LastDllError)
Exit Function
End If
Dim MyString As String
' Get a string from the Resource DLL
strString = ""
Try
lngStringLen = FMain.LoadString(hLibrary, 10001, strString, Len(strString))
'If lngStringLen <> 0 Then Me.Caption = Left(strString, lngStringLen)
Catch
MsgBox("Error during loadString...", MsgBoxStyle.Exclamation Or MsgBoxStyle.OKOnly, "Error in DLL function")
End Try
MyForm.Refresh()
' Close the Resource DLL
FMain.FreeLibrary(hLibrary)
End Function
in my main form, i have my DLL functions declared like that :
Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Public Declare Function LoadString Lib "user32" Alias _
"LoadStringA" (ByVal hInstance As Long, ByVal wID As Long, _
ByVal lpBuffer As String, ByVal nBufferMax As Long) As Long
-------------------
i still have the same problem, in LoadString, but i don't understand why and where ?
if try ...catch is not here...i have error message : "An unhandled exception of type 'System.NullReferenceException' occurred in DLL_test1.exe"
thanks to help me, because i'm becoming crazy with this error :(
Maileen