473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

using DLL from Visual C++.net

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
3 1501
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
10
by: Jonathan Wilson | last post by:
Firstly, to get msvcrt.lib, install the .NET framework SDK. The version of msvcrt.lib included there is the exact same one as comes with Visual Studio ..NET 2003. There are some other things that...
5
by: Charlie | last post by:
I am a student taking a computer class programmning with ms visual C++. The college is using ms visual C++ 6.0 on it's computers. I purchased ms visual studio.net (Academic) (ver 2003) which is...
13
by: kamaraj80 | last post by:
Hi I am using the std:: map as following. typedef struct _SeatRowCols { long nSeatRow; unsigned char ucSeatLetter; }SeatRowCols; typedef struct _NetData
0
by: ME | last post by:
I can't seem to delete records using an objectdatasource. The object is a Typed Collection built by Visual Studio that access a SQL Database. When I try to delete using the ObjectDataSource it...
0
by: vishal.nagota | last post by:
I'm making a project on vc++ express I want to plot graphs, so using MSChart evrything goes fine, till i come to point where I've to include afxdisp.h by defualt i'm using Project properties...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
2
by: lewisms | last post by:
Hello all, I am quite new to c++/. Net so please don't shoot me down for being a newbie. Any way I am trying to make a simple multithreading program that is just to learn the ideas behind it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.