all groups > visual c libraries > november 2003 >
You're in the

visual c libraries

group:

Calling VC++.NET DLLEXPORT Function in VB6 (Error 453: Can't find DLL entry point xx in yy.dll)


Re: Calling VC++.NET DLLEXPORT Function in VB6 (Error 453: Can't find DLL entry point xx in yy.dll) Ronald Laeremans [MSFT]
11/17/2003 1:37:35 PM
visual c libraries:
Make sure this is in an extern "C" block.

Have you looked at the DLL exports using dumpbin or depends or some other
tool?

Ronald Laeremans
Visual C++ team

[quoted text, click to view]

Calling VC++.NET DLLEXPORT Function in VB6 (Error 453: Can't find DLL entry point xx in yy.dll) Joe Hoggood
11/17/2003 4:24:42 PM
I am trying to call a VC++.NET exported function (Win32 DLL) in VB6. When I
try to call this exported function from VB6 I get the following error: Error
453: Can't find DLL entry point xx in yy.dll

VC++.NET cpp/h source:

// Win32DLL.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"

#include "Win32DLL.h"

BOOL APIENTRY DllMain(

HANDLE hModule,

DWORD ul_reason_for_call,

LPVOID lpReserved

)

{

switch (ul_reason_for_call)

{

case DLL_PROCESS_ATTACH:

case DLL_THREAD_ATTACH:

case DLL_THREAD_DETACH:

case DLL_PROCESS_DETACH:

break;

}


return TRUE;

}

// This is an example of an exported variable

WIN32DLL_API public int nWin32DLL = 0;

// This is an example of an exported function.

WIN32DLL_API public int fnWin32DLL(int varIn)

{

int varOut;

varOut = varIn;

return varOut;

}

// This is the constructor of a class that has been exported. See Win32DLL.h
for the class definition

CWin32DLL::CWin32DLL()

{

return;

}


#ifdef WIN32DLL_EXPORTS

#define WIN32DLL_API __declspec(dllexport)

#else

#define WIN32DLL_API __declspec(dllimport)

#endif

// This class is exported from the Win32DLL.dll

class WIN32DLL_API CWin32DLL

{

public:

CWin32DLL(void);

// TODO: add your methods here.

};

extern WIN32DLL_API int nWin32DLL;

WIN32DLL_API int fnWin32DLL(int varIn);



Here's my VB6 tester code:

'Set up global declarations and declare functions.
Declare Function fnWin32DLL Lib
"C:\jhoggood\Applications\CommonC\BuildFiles\Win32DLL\Debug\Win32DLL.dll"
(ByVal varIn As Integer) As Integer

Public Function DoExternFunc(myInputVarA As Integer) As Integer
' Call external function
DoExternFunc = fnWin32DLL(myInputVarA)
Debug.Print myResult
End Function


Private Sub cmdCompute_Click()
Dim x As Integer
x = DoExternFunc(4)
txtInputVarA.Text = x
End Sub







Re: Calling VC++.NET DLLEXPORT Function in VB6 (Error 453: Can't find DLL entry point xx in yy.dll) Joe Hoggood
11/17/2003 4:48:09 PM
Yes, I have looked using Dependency Walker V2.1 and the exported function
"fnWin32DLL" is there. What should my extern declarations look like in the
h/cpp files?

Thanks!




[quoted text, click to view]

Re: Calling VC++.NET DLLEXPORT Function in VB6 (Error 453: Can't find DLL entry point xx in yy.dll) Ronald Laeremans [MSFT]
11/18/2003 11:44:13 AM
Thanks for the follow-up.

Ronald

[quoted text, click to view]

Re: Calling VC++.NET DLLEXPORT Function in VB6 (Error 453: Can't find DLL entry point xx in yy.dll) Joe Hoggood
11/18/2003 2:10:40 PM
Turns out this is a VB6 bug where you must run the application from an EXE
(File/Make EXE) otherwise you will get the following error:

Run-time error: '49' Bad DLL calling convention



[quoted text, click to view]


Re: Calling VC++.NET DLLEXPORT Function in VB6 (Error 453: Can't find DLL entry point xx in yy.dll) Mattias Sjögren
11/18/2003 10:40:01 PM
Joe,

[quoted text, click to view]

This is not a bug, it's just a limitation in VB6. It only supports the
stdcall calling convention, so you must use that for your exported
functions if you want to call them from VB.

The reason you only see the runtime error in the IDE is that the
checks that have to be done to dicover the calling convention mismatch
are not performed in a compiled executable for performance reasons. It
does not mean that you can ignore the error you get.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
AddThis Social Bookmark Button