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

CodePudding user response:

refer to the original poster u010083399 response:
final purpose is to find a way to let the DLL in VC and VB wrote JAVA can call


VC with the JAVA can call COM components?

CodePudding user response:

VC can invoke the com component

CodePudding user response:

reference myjian reply: 3/f
refer to the original poster u010083399 response: the final purpose is to find a way to let the DLL in VC and VB wrote JAVA can call

VC with the JAVA can call COM components?

VC and JAVA can be called COM components,

CodePudding user response:

refer to the original poster u010083399 response:
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 file is 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:
Fun...

Hello:
Now online said those generated by the method of using VB to compile two standard DLL method is just based on the "Declare in VB Function... "To call, call in VC or JAVA couldn't achieve it,
That our teacher gave me a task is no solution, he give me some information on VB first two compilation process when the LINK to add an EXPORT options for some of the ways, I use your plug-in ready DLL, VB can be adjustable, using VC appears problem,
Our teacher is think of using VB to do some control is simple, direct written in C very troublesome, and he says those methods is also very troublesome to register, in computer and then to register, his main program was written in C and JAVA, so want to do a standard DLL function library for VC and JAVA program calls,
If you have any solution can give me the direction I continue to study it, thanks.

CodePudding user response:

Look at this article:
http://blog.csdn.net/supermanking/article/details/3082809

CodePudding user response:

You remove the sentence msgbox try

CodePudding user response:

VB wrote don't have to register the DLL (the so-called standard DLL, in fact is not standard, because it to invoke a VB a DLL library files), the function of digital processing, I tested, using c + +, VFP calls are successful.
But about the character, seemingly cross-language temporarily no, take time to go to see again.

CodePudding user response:

VB series processing function to initialize the environment to use, because of your DLL initialization to VB, of course there is a problem

CodePudding user response:

String is complicated, because involves the character set conversion.

Reference:

http://www.m5home.com/bbs/thread-1698-1-1.html

CodePudding user response:

I don't know off the building are not done, I write DLL using vc call succeeded, but only under the xp can run normally, under the 64 - bit Windows 7 is an error,
And 64 - bit Windows 7 under vb call is normal, it's strange,

CodePudding user response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, changed its name to bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?

CodePudding user response:

DLLMAIN function parameters and return values must be for long
In addition, the export of the custom function calls, if to other language parameter, the return value is the most useful long type, and best use byval, other problems of your code

CodePudding user response:

To say how the teacher also enough wonderful work, you can out of this topic is
This violation of normal use function approach, personally think that should not appear in the teaching, or should not focus on the application, point to the can

CodePudding user response:

Has the progress, thank you,

CodePudding user response:

reference 15 floor PctGL response:
to say you this teacher also enough wonderful work, how can this topic
This violation of normal use function approach, personally think that should not appear in the teaching, or should not focus on the application, point to can
  •  Tags:  
  • API
  • Related