By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,326 Members | 881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,326 IT Pros & Developers. It's quick & easy.

crazy DLL resources

P: n/a

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 = ""

lngStringLen = FMain.LoadString(hLibrary, 10001, strString, Len(strString))
'If lngStringLen <> 0 Then Me.Caption = Left(strString, lngStringLen)
MsgBox("Error during loadString...", MsgBoxStyle.Exclamation Or MsgBoxStyle.OKOnly, "Error in DLL function")
End Try


' Close the Resource DLL
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 :(

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hi Maileen,

Your Declares are buggy.
See my response to your previous post for details.


Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.