Home > Software engineering > Standard DLL written in VB, use among the plug-in, VC call not, couldn't find a clue
Standard DLL written in VB, use among the plug-in, VC call not, couldn't find a clue
Time:10-03
I use the online download "DLL - VB_DLL_Link plug-in," according to the above method generates a simple addition function in VB6.0 by use of the DLL, using VB to test the call is successful, but in the VC call but there is a problem, I have put the function. The DLL files are copied to the VC test project folder below, the caller didn't complain, but run time will pop-up window said dllcall1 exe has stopped work,
Below is the VB function code: DLL
function. The Function DllMain (ByVal hInstDLL As Double, ByVal fdwReason As Double, ByVal lpwReserved As Double) As a Double DllMain=1 End the Function Sub Main ()
End Sub The Function to the Add (ByVal A As Double, ByVal B As Double) As A Double MsgBox A + B The Add=A + B End the Function
Private Sub M As String (s) MsgBox s, vbInformation End Sub
Here is my VC caller:
dllcall1. CPP
# include & lt; Stdio. H> # include & lt; Windows. H> Typedef int (* lpAddFun) (int, int). Int main (int arg c, char * argv []) { HINSTANCE hDll; LpAddFun addFun; HDll=LoadLibrary (" function. DLL "); If (hDll!=NULL) { AddFun=(lpAddFun) GetProcAddress call (hDll, "Add"); If (addFun!=NULL) { Int result=addFun (2, 3); Printf (" % d ", result); } FreeLibrary (hDll); } return 0; } \ \ test VC to write a DLL is no problem,
I am a beginner, the teacher gave a task, the final purpose is to find a way to let the DLL in VC and VB wrote JAVA can call, From looking for information to write programs for two weeks, now have no clue, don't know if the VB and VC data interface problem, If we can get help, I would be grateful, Thank you,
CodePudding user response:
VB can't write standard DLL, do you think the hack would, making VB standard module function is added to the export table method works well, the fact that something is coaxing rookie,
CodePudding user response:
Typedef int (* lpAddFun) (int, int).
The statement is wrong, the DLL statement is double