[Dev-C++] help needed with calling dll from Visual basic
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ni J. <ni_...@ba...> - 2004-11-04 14:11:21
|
Hi, All.
=20
I am writing to ask for help from the Dev-C++ user community with the
problem of calling dll from visual basic.
=20
I wrote a dll by using Dev-C++ and the dll works fine with an interface
written in Dev-C++. However, when I tried to call the dll from an =
interface
written in visual basic, I run into problem.
=20
1. The dll contains a function with prototype shown below. It
concatenates the time to the string "name".
=20
Void reportTime (char *name);
=20
I call the function in dll from visual basic by using the
following declare statement
=20
Private Declare Sub reportTime Lib =
"c:\dlltest-4\dlltest-4.dll"
(ByVal name As String)
=20
I get an error message "bad dll calling convention". =20
=20
2. So I made some change to the prototype of the function in dll by
adding _stdcall as shown below.
=20
Void _stdcall reportTime (char *name);
=20
The declare statement is the same in the visual basic interface.
=20
This time, I do not get the error message shown above and I can tell =
that
the string "name" is passed into dll and the function can concatenate =
the
time to the string. However, after the dll returns the control back to =
the
interface, the string "name" in the interface does not reflect the
manipulation done in dll. I do not know what to do.=20
=20
Thank you in advance for your time and help.
=20
Jean Ni
=20
=20
|