VB can't find entry point in VC++ DLL 
Author Message
 VB can't find entry point in VC++ DLL

I saw a similar question asked before but no answer, so I'll ask now.

I have written a DLL in Visual C++ that I need to call from a form in
VB.  The DLL works fine when I call it from a C program, but when I call
it from my VB form it gives me an error:
(Run-time error '453': Can't find DLL entry point Create_User in
create_user.dll).

I exported the function in the DLL with the statement (it is the only
function in the DLL at this point):

_declspec(dllexport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
Password, LPSTR Home_Dir, LPSTR Comment );

In the VB form I declared it with:

Private Declare Function Create_User Lib "create_user.dll" ( ByRef
Username As String, ByRef Password As String, ByRef HomeDir As String,
ByRef Comment As String) as Integer

It is then called with (info from four text fields is the input and it
returns an Integer with the status of the API call):

status = create_user(Username.Text, Password.Text, HomeDir.Text,
Comment.Text)

In the C program I wrote initially to test the DLL, I imported it with
_declspec(dllimport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
Password, LPSTR Home_Dir, LPSTR Comment );
and it worked just fine.

This is on a Windows NT4.0 server that I'm doing this all on.  I'm
fairly new to Visual Basic and pretty much have no clue why it doesn't
work.  I did look through the last 6 months of the web archive for the
list and couldn't find anything that seemed to cover this, so if anyone
can help I would greatly appreciate it



Sat, 16 Dec 2000 03:00:00 GMT  
 VB can't find entry point in VC++ DLL

Quote:

> I saw a similar question asked before but no answer, so I'll ask now.

> I have written a DLL in Visual C++ that I need to call from a form in
> VB.  The DLL works fine when I call it from a C program, but when I call
> it from my VB form it gives me an error:
> (Run-time error '453': Can't find DLL entry point Create_User in
> create_user.dll).

> I exported the function in the DLL with the statement (it is the only
> function in the DLL at this point):

> _declspec(dllexport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
> Password, LPSTR Home_Dir, LPSTR Comment );

> In the VB form I declared it with:

> Private Declare Function Create_User Lib "create_user.dll" ( ByRef
> Username As String, ByRef Password As String, ByRef HomeDir As String,
> ByRef Comment As String) as Integer

I think all these should be ByVal and not ByRef. That is a difference I
thought I found in VB, i.e., if it is an int or any other type of that kind,
ByVal, passes it by Value, where as for a string a ByVal passes the
pointer.(I might be mistaken.) I think in the previous question, the
parameter passed was an integer and was passed ByVal.

- Show quoted text -

Quote:
> It is then called with (info from four text fields is the input and it
> returns an Integer with the status of the API call):

> status = create_user(Username.Text, Password.Text, HomeDir.Text,
> Comment.Text)

> In the C program I wrote initially to test the DLL, I imported it with
> _declspec(dllimport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
> Password, LPSTR Home_Dir, LPSTR Comment );
> and it worked just fine.

> This is on a Windows NT4.0 server that I'm doing this all on.  I'm
> fairly new to Visual Basic and pretty much have no clue why it doesn't
> work.  I did look through the last 6 months of the web archive for the
> list and couldn't find anything that seemed to cover this, so if anyone
> can help I would greatly appreciate it



Sat, 16 Dec 2000 03:00:00 GMT  
 VB can't find entry point in VC++ DLL

It's been my experience that __declspec( export ) does not work when
exporting functions for VB.  Perhaps I am doing something wrong too.
However, explicitly exporting a the desired function in a .DEF file and
declaring the function with the CALLBACK directive has always worked.

C Example:

void CALLBACK MyFunction()
{

Quote:
}

VB Example
Private Declare Sub MyFunction Lib "MyFunction" ()

I'll attach a working example separately.

--
Increase the Peace!
Charles LaCour

Quote:

>I saw a similar question asked before but no answer, so I'll ask now.

>I have written a DLL in Visual C++ that I need to call from a form in
>VB.  The DLL works fine when I call it from a C program, but when I call
>it from my VB form it gives me an error:
>(Run-time error '453': Can't find DLL entry point Create_User in
>create_user.dll).

>I exported the function in the DLL with the statement (it is the only
>function in the DLL at this point):

>_declspec(dllexport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
>Password, LPSTR Home_Dir, LPSTR Comment );

>In the VB form I declared it with:

>Private Declare Function Create_User Lib "create_user.dll" ( ByRef
>Username As String, ByRef Password As String, ByRef HomeDir As String,
>ByRef Comment As String) as Integer

>It is then called with (info from four text fields is the input and it
>returns an Integer with the status of the API call):

>status = create_user(Username.Text, Password.Text, HomeDir.Text,
>Comment.Text)

>In the C program I wrote initially to test the DLL, I imported it with
>_declspec(dllimport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
>Password, LPSTR Home_Dir, LPSTR Comment );
>and it worked just fine.

>This is on a Windows NT4.0 server that I'm doing this all on.  I'm
>fairly new to Visual Basic and pretty much have no clue why it doesn't
>work.  I did look through the last 6 months of the web archive for the
>list and couldn't find anything that seemed to cover this, so if anyone
>can help I would greatly appreciate it



Sun, 17 Dec 2000 03:00:00 GMT  
 VB can't find entry point in VC++ DLL

Quote:

> I saw a similar question asked before but no answer, so I'll ask now.

> I have written a DLL in Visual C++ that I need to call from a form in
> VB.  The DLL works fine when I call it from a C program, but when I call
> it from my VB form it gives me an error:
> (Run-time error '453': Can't find DLL entry point Create_User in
> create_user.dll).

> I exported the function in the DLL with the statement (it is the only
> function in the DLL at this point):

> _declspec(dllexport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
> Password, LPSTR Home_Dir, LPSTR Comment );

Erik -


the size of the arguments in bytes.

Run dumpbin /exports on your DLL, and you'll see the exported names.
For example:

In the DLL:

extern "C"
{
__declspec( dllexport ) int __stdcall ParseBusy(char *str, int
PeriodLen) ;

dumpbin says:



HTH,
Tim.

Please reverse ku for my real address.



Sun, 17 Dec 2000 03:00:00 GMT  
 VB can't find entry point in VC++ DLL

Thanks everyone for the quick response. Charles and Roger hit it right on
the head.  As soon as I switched to using a .DEF file to export instead of
_declspec(dllexport) and tweaked a couple of minor things it worked just
fine.

Quote:

> I saw a similar question asked before but no answer, so I'll ask now.

> I have written a DLL in Visual C++ that I need to call from a form in
> VB.  The DLL works fine when I call it from a C program, but when I call
> it from my VB form it gives me an error:
> (Run-time error '453': Can't find DLL entry point Create_User in
> create_user.dll).

> I exported the function in the DLL with the statement (it is the only
> function in the DLL at this point):

> _declspec(dllexport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
> Password, LPSTR Home_Dir, LPSTR Comment );

> In the VB form I declared it with:

> Private Declare Function Create_User Lib "create_user.dll" ( ByRef
> Username As String, ByRef Password As String, ByRef HomeDir As String,
> ByRef Comment As String) as Integer

> It is then called with (info from four text fields is the input and it
> returns an Integer with the status of the API call):

> status = create_user(Username.Text, Password.Text, HomeDir.Text,
> Comment.Text)

> In the C program I wrote initially to test the DLL, I imported it with
> _declspec(dllimport) NET_API_STATUS Create_User( LPSTR Username, LPSTR
> Password, LPSTR Home_Dir, LPSTR Comment );
> and it worked just fine.

> This is on a Windows NT4.0 server that I'm doing this all on.  I'm
> fairly new to Visual Basic and pretty much have no clue why it doesn't
> work.  I did look through the last 6 months of the web archive for the
> list and couldn't find anything that seemed to cover this, so if anyone
> can help I would greatly appreciate it

--

Web Page, and Resume: http://homepages.uc.edu/~pfingsea/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-(---) s:+ a- C++++ ULUHO++$ P+++$ L+++$ E W+++$ N+ !o !K w+$ !O
M+$ V PS+++ PE+ Y+ PGP++ t 5+++ X R+ tv b++ DI++++ D++ G e>++ h- r- y++
------END GEEK CODE BLOCK------


Sun, 17 Dec 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VB Can't Find DLL Entry Point

2. VB5 DLL function / Can't find DLL entry point

3. dll creation problem: can't find dll entry point

4. VB5 DLL Error - Can't Find Entry Point in ...dll

5. dll creation problem: can't find dll entry point

6. VB5 DLL Error - Can't Find Entry Point in ...dll

7. Can't find DLL entry point OpenEventLog in advapi32.dll

8. Can't find DLL entry point NetGetDCName in netapi32.dll

9. Can't find DLL entry point NetRemoteTOD in NETAPI32.DLL

10. Can't find DLL entry-point ...??

11. Can't find DLL Entry point ExitWindows in user32

12. Newbie Question: Can't find DLL entry point

 

 
Powered by phpBB® Forum Software