G
Guest
I use the C++ to write a dll and call the dll using VB6
VC++ Code
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserve
return TRUE
int WINAPI MyDLLAdd(int d1, int d2
return (d1+d2)
int WINAPI MyDLLSub(int d1, int d2
return (d1-d2)
VB code
Declare Function MyAdd Lib "MyDLL.dll" Alias "MyDLLAdd" (ByVal data1 As Integer, ByVal data2 As Integer) As Intege
Private Sub Calc_Click(
Dim m As Intege
Dim n As Intege
m = Val(Text1.Text
n = Val(Text2.Text
Text3.Text = MyAdd(m, n
End Su
I run the VB and get the right answer. But when I debug my dll using VC++6. if I call MyAdd(3,2), then MyDLLAdd(int d1, int d2) d1(d1=1073741826) is not 3 and d2(d2=1074266115) is not 2.
What is wrong?
VC++ Code
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserve
return TRUE
int WINAPI MyDLLAdd(int d1, int d2
return (d1+d2)
int WINAPI MyDLLSub(int d1, int d2
return (d1-d2)
VB code
Declare Function MyAdd Lib "MyDLL.dll" Alias "MyDLLAdd" (ByVal data1 As Integer, ByVal data2 As Integer) As Intege
Private Sub Calc_Click(
Dim m As Intege
Dim n As Intege
m = Val(Text1.Text
n = Val(Text2.Text
Text3.Text = MyAdd(m, n
End Su
I run the VB and get the right answer. But when I debug my dll using VC++6. if I call MyAdd(3,2), then MyDLLAdd(int d1, int d2) d1(d1=1073741826) is not 3 and d2(d2=1074266115) is not 2.
What is wrong?