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 C++.net

P: n/a
Hi,

I've created 2 dll with VC++.net, 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,
Maileen
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:

http://www.gotdotnet.com/Community/U...2-CA46EF086C12

Crouchie1998
BA (HONS) MCP MCSE
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,
Maileen

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

http://www.gotdotnet.com/Community/U...2-CA46EF086C12

Crouchie1998
BA (HONS) MCP MCSE

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)
MyBase.OnClick(e)
Dim hMSGina As IntPtr =
LoadLibrary(Environment.ExpandEnvironmentVariables ("%WINDIR%\System32\ms
gina.dll"))
Dim MyString As New System.Text.StringBuilder(256)
LoadString(hMSGina, 1525, MyString, MyString.Capacity)
FreeLibrary(hMSGina)
MessageBox.Show(MyString.ToString)
End Sub
~

I hope it helps,
Roman
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.