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

using DLL from Visual

P: n/a

I've created 2 dll with, which are only resource dlls.
in fact, only strings are inside.

IDS_String101 101 Welcome
IDS_String102 102 Bye

where IDS_Stringxxx is the ID, 101 is the valueID and Welcome the value of this string

to load and display resource string dll value, here is my code :

' Load the Resource DLL
hLibrary = LoadLibrary("myapp\english.dll")
If hLibrary = 0 Then
MsgBox "Failed to load the specified library with error code " & Err.LastDllError
Exit Sub
End If
' Get a string from the Resource DLL
dim strString as string
dim lngStringLen as Long
lngStringLen = LoadString(hLibrary, 101, strString, Len(strString))
Form1.Label1.Text = Left(strString, lngStringLen)

but an error occur on :
lngStringLen = LoadString(hLibrary, 101, strString, Len(strString))

something like systemNull.xxxx
why ?

thanks a lot,
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
Take a look at this example as i think it will help:

Nov 21 '05 #2

P: n/a
thanks a lot,

but i place resources in this DLL, and how to get them from this DLL to my VB application ?

thanks a lot,

Crouchie1998 wrote:
Take a look at this example as i think it will help:


Nov 21 '05 #3

P: n/a
Hi Maileen,

I see that you use Long for a return value of LoadString, so you
probably use bad Declare statements.
Try this sample instead:

Friend Declare Auto Function LoadLibrary Lib "kernel32.dll" ( _
<MarshalAs(UnmanagedType.LPTStr), [In]()> ByVal lpFileName As
String _
) As IntPtr
Friend Declare Auto Function LoadString Lib "user32.dll" ( _
ByVal hInstance As IntPtr, _
ByVal uID As Integer, _
<MarshalAs(UnmanagedType.LPTStr)> ByVal lpBuffer As
System.Text.StringBuilder, _
ByVal nBufferMax As Integer _
) As Integer
Friend Declare Function FreeLibrary Lib "kernel32.dll" ( _
ByVal hModule As IntPtr _
) As Boolean

Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
Dim hMSGina As IntPtr =
LoadLibrary(Environment.ExpandEnvironmentVariables ("%WINDIR%\System32\ms
Dim MyString As New System.Text.StringBuilder(256)
LoadString(hMSGina, 1525, MyString, MyString.Capacity)
End Sub

I hope it helps,
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.