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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling DLL function from VB

Status
Not open for further replies.

raochetan

Programmer
Aug 20, 2001
62
IN
Hi All,

I have created a simple DLL with Win32 Application Extension Wizard. I have a a couple of function that are to called from a VB project. Thus I have set the calling convension to __stdcall in the Project Settings. In VB I have used the following syntax:

Private Declare Function fTest Lib &quot;<Path of Dll>&quot; Alias &quot;fnTest&quot; () as Long

Private Sub Command1_Click()
Dim r as Long
r = fTest()
End Sub

I am receving a error message saying
Error: 453 Can't Find Dll Entry Point for fTest

I have also observed that it is DllMain call is successfull.

Please let me know what is problem in the code. The code is below:

Header File:

#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif

#if defined(__cplusplus)
extern &quot;C&quot;{
#endif

TEST_API int fnTest(void);

#if defined(__cplusplus)
}
#endif


Implementation File:

#include &quot;stdafx.h&quot;
#include &quot;test.h&quot;

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
MessageBox(NULL, &quot;From Dll Main&quot;, &quot;From Test Dll&quot;, MB_ICONASTERISK);
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 function.
TEST_API int fnTest(void)
{
MessageBox(NULL, &quot;Success!! Test Message&quot;, &quot;From Test Dll&quot;, MB_ICONASTERISK);
return 42;
}


Thanks In Advance

regards
raochetan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top