PLEASE HELP ! : Calling DLL in 32bit VB4.0 
Author Message
 PLEASE HELP ! : Calling DLL in 32bit VB4.0

--------------AFD3EE49CDC6055D6B7E70E5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm having problems calling a function in a C++ DLL. The DLL is found by
the VB app, but gives an error ("Run-time error '453': Specified DLL
function not found). This is how I have the DLL declared in the projects
module file :

Declare Function TestFunction Lib "test.dll" (ByVal word1 As String,
ByVal word2 As String, ByVal word3 As String, ByVal word4 As String)

And this is how I call the Function :

returnVal = TestFunction(ByVal word1, ByVal word2, ByVal word3, ByVal
word4)

The DLL is built with Visual C++ version 4.1, and I have the
source-code. The function takes 4 parameters - all pointers to strings.

WHAT AM I DOING WRONG ???
Thanks in advance !

Mark.

--------------AFD3EE49CDC6055D6B7E70E5
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
I'm having problems calling a function in a C++ DLL. The DLL is found by
the VB app, but gives an error ("Run-time error '453': Specified DLL function
not found). This is how I have the DLL declared in the projects module
file :
<BR>?

<P><B>Declare Function TestFunction Lib "test.dll" (ByVal word1 As String,
ByVal word2 As String, ByVal word3 As String, ByVal word4 As String)</B>

<P>And this is how I call the Function :

<P><B>returnVal = TestFunction(ByVal word1, ByVal word2, ByVal word3, ByVal
word4)</B><B></B>

<P>The DLL is built with Visual C++ version 4.1, and I have the source-code.
The function takes 4 parameters - all pointers to strings.
<BR>?

<P>WHAT AM I DOING WRONG ???
<BR>Thanks in advance !

<P>Mark.
<BR>?
<BR>?</HTML>

--------------AFD3EE49CDC6055D6B7E70E5--



Mon, 01 May 2000 03:00:00 GMT  
 PLEASE HELP ! : Calling DLL in 32bit VB4.0

This is a multi-part message in MIME format.

------=_NextPart_000_0044_01BCF0A1.58380B00
Content-Type: text/plain;
        charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Declare Function TestFunction Lib "test.dll" (ByVal word1 As String, =
ByVal word2 As String, ByVal word3 As String, ByVal word4 As String)=20
   =20
   =20
   =20
    You need to use Alias, because you are dealing with string =
variables. Try following:
   =20
    Declare Function TestFunction Lib "test.dll" Alias "TestFunctionA" =
...
   =20
    That should help you!
   =20
    =20
   =20
    Thomas
   =20
   =20
   =20

------=_NextPart_000_0044_01BCF0A1.58380B00
Content-Type: text/html;
        charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
    <P><B>Declare Function TestFunction Lib &quot;test.dll&quot; (ByVal =
word1 As=20
    String, ByVal word2 As String, ByVal word3 As String, ByVal word4 As =

    String)</B>=20
    <P>&nbsp;
    <P><FONT color=3D#000000 size=3D2>You need to use Alias, because you =
are dealing=20
    with string variables. Try following:</FONT></P>
    <P><FONT color=3D#000000 size=3D2>Declare Function TestFunction Lib=20
    &quot;test.dll&quot; Alias &quot;TestFunctionA&quot; ...</FONT></P>
    <P><FONT size=3D2>That should help you!</FONT></P>
    <P><FONT size=3D2></FONT>&nbsp;</P>
    <P><FONT size=3D2>Thomas</FONT></P>
    <P>&nbsp;</P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0044_01BCF0A1.58380B00--



Tue, 02 May 2000 03:00:00 GMT  
 PLEASE HELP ! : Calling DLL in 32bit VB4.0

Quote:

>Declare Function TestFunction Lib "test.dll" (ByVal word1 As String,
>ByVal word2 As String, ByVal word3 As String, ByVal word4 As String)

>And this is how I call the Function :

>returnVal = TestFunction(ByVal word1, ByVal word2, ByVal word3, ByVal
>word4)

Ah, don't do that: you're using Byval BOTH in the declaration and in the
function call. Remove all Byval's from the function call.

Second, does the function exist under that name? Try (in Win95) to
right-click on the DLL-file, and see what name the function has been
exported as. Probably it's NOT TestFunction. My bet is that the name has
been mangled by VC. You'll have to declare the function properly in the
EXPORTS section, but I'm not fluent enough with C to tell you exactly
how this should be done.

HTH,
Bart.



Sat, 06 May 2000 03:00:00 GMT  
 PLEASE HELP ! : Calling DLL in 32bit VB4.0

Just a couple of things about this.    I assume since you are passing them
as byval that the procedure does not attempt to modify them so this is
probably a mute argument.     But if by some chance the procedure wants to
modify any of the passed parameters then one thing you might want to do is
predefine the word1, word2, word3 and word4 strings and fill them with
blanks and pass them by reference.   In this case Visual Basic passes an
uninitialized string as a NULL and the DLL functions usually don't like
this.   Again, this is only if the dll wants to modify and return the
parameter.

Word1 = string(length,"  ")

Another thing that Mark suggested is that the actual name of the procedure
may not be what you think it is.   I'm not sure just looking at the
properties of the DLL is going to tell you the procedure names but there is
something else you can do.    If you have a hex editor you can load the DLL
into it and search for what you believe to be the name of the function.  
When it finds it, note if it has any additional characters before or after
the name and use the "ALIAS" keyword added to your declaration to call out
the procedure name.



Quote:

> >Declare Function TestFunction Lib "test.dll" (ByVal word1 As String,
> >ByVal word2 As String, ByVal word3 As String, ByVal word4 As String)

> >And this is how I call the Function :

> >returnVal = TestFunction(ByVal word1, ByVal word2, ByVal word3, ByVal
> >word4)

> Ah, don't do that: you're using Byval BOTH in the declaration and in the
> function call. Remove all Byval's from the function call.

> Second, does the function exist under that name? Try (in Win95) to
> right-click on the DLL-file, and see what name the function has been
> exported as. Probably it's NOT TestFunction. My bet is that the name has
> been mangled by VC. You'll have to declare the function properly in the
> EXPORTS section, but I'm not fluent enough with C to tell you exactly
> how this should be done.

> HTH,
> Bart.



Sat, 06 May 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Prob calling VC++ 4.0 DLL from VB4 (32bit)

2. Any sample VB4 program with calls to 32bit dlls

3. Any sample VB4 program with calls to 32bit dlls

4. Help on Update in VB4 32bit please

5. 16bit->32bit C dll : bad dll calling convention

6. Calling DLL function troubles - please, please help!!!

7. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

8. Calling Dial-Up Networking from VB4-32bit

9. Calling Dial-Up Networking from VB4-32bit

10. Call 16-bit dll from 32bit apps??

11. Debugging a 32bit DLL called from a VB app

12. calling 32bit dll's

 

 
Powered by phpBB® Forum Software