X
xin.huang.xh
Hi All:
Please help me out here. I try to call a C++ dll from my VB.NET code.
I follow the examples given on the web, but it does not work for
me!!! It drives me crazy, so please help me out. Here is what I did
Create an empty VC++ dll project from Visual Studio 2003. Create a
test.cpp file and add the following
long _stdcall test(long a) {
return a;
}
Create a test.def file and add the following
LIBRARY "test"
EXPORTS
test
Create a VB windows application. Here is what is given in the file
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function test Lib "location of the dll in my
computer" (ByVal b As Long) as Long
Private Sub Button1_Click( ..... ) Handles Button1.Click
MsgBox(test(1000))
End Sub
End Class
When I click the button, it returns a number that is very large (so
it
is NOT 1000).
I also try the same thing in VS2005 on another machine in my lab.
This time I get an error
PInvokeStackImbalance was detected
I just don't know what is going on. It just a very simple example and
just cannot get it work.
So, any suggestions will be much appreciated,
Thanks alot
Xin
Please help me out here. I try to call a C++ dll from my VB.NET code.
I follow the examples given on the web, but it does not work for
me!!! It drives me crazy, so please help me out. Here is what I did
Create an empty VC++ dll project from Visual Studio 2003. Create a
test.cpp file and add the following
long _stdcall test(long a) {
return a;
}
Create a test.def file and add the following
LIBRARY "test"
EXPORTS
test
Create a VB windows application. Here is what is given in the file
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function test Lib "location of the dll in my
computer" (ByVal b As Long) as Long
Private Sub Button1_Click( ..... ) Handles Button1.Click
MsgBox(test(1000))
End Sub
End Class
When I click the button, it returns a number that is very large (so
it
is NOT 1000).
I also try the same thing in VS2005 on another machine in my lab.
This time I get an error
PInvokeStackImbalance was detected
I just don't know what is going on. It just a very simple example and
just cannot get it work.
So, any suggestions will be much appreciated,
Thanks alot
Xin