Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL proyect to be used into VBasic (VisualStudio98)

Status
Not open for further replies.

arlequin

Programmer
Sep 21, 1999
232
0
0
UY
Hi, people.<br>
I want to run a function defined into a DLL from VB.<br>
P.E., a simple stupyd example...<br>
<br>
long sum (int s1, int s2);<br>
<br>
-----<br>
------ DLLmain developed by the DLL wizard itself<br>
-----<br>
long sum (int s1, int s2)<br>
{<br>
return (s1 + s2)<br>
}<br>
<br>
OK, I compile this and correctly declare in VB Module<br>
but an error was found during the invocation in VB:<br>
<br>
res = sum ( 1 + 1 )<br>
<br>
something that the entry of the DLL couln't be found<br>
<br>
What this?!<br>

 
Was that dll an Extension Dll or a regular dll<br>
cos if you are using an extension dll<br>
it can be used only by MFC<br>
and did you put the function in your exports.<br>
i.e .def file.<br>
<br>
Do one thing create a dll which is statically linked to mfc<br>
and say you want to use <br>
Sum(int,int) of the Dll in your VB app<br>
in your def file put<br>
Sum=_Sum@4<br>
and declare the function in yopur dll as.<br>
<br>
extern &quot;C&quot;<br>
{<br>
int __declspec( dllexport ) _stdcall Sum(int,int);<br>
}<br>
trying doing this,<br>
hope it helps.<br>
<br>
-Sun<br>
All the best.<br>
<br>

 
arlequin --<br>
Like I replied to you in the VB forum (and like Sun said), you need to make sure your function is visible outside the DLL. To do that, preface your function with APIENTRY<br>
&nbsp;&nbsp;&nbsp;&nbsp;int APIENTRY Sum(int s1, int s2)<br>
<br>
Another technique is to do like Sun said and use declspec with dllexport. Six of one, Half Dozen of the other -- use the one you feel most comfortable with.<br>
<br>
Chip H.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top