A simple DLL project

  • Thread starter Thread starter Enoch Chan
  • Start date Start date
E

Enoch Chan

I would like learn how to use VC++ 6.0 Stantard edition to
build a DLL. I used the VC++ option "A DLL that exports
some symbols" to generate a complete project for me. The
following is the source file, int fnTest(void) will be
exported.

// test.cpp : Defines the entry point for the DLL
application.
//

#include "stdafx.h"
#include "test.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
__declspec( dllexport ) int nTest=0;

// This is an example of an exported function.
__declspec( dllexport ) int fnTest(void)
{
return 42;
}

// This is the constructor of a class that has been
exported.
// see test.h for the class definition
CTest::CTest()
{
return;
}

I have not change anything and build a dll.

However when I try to use VB6 to call this dll function by
using the following VB code

Declare Function fnTest Lib "test" () As Integer

Sub callaDLL()
Dim x As Integer
x = fnTest()
End Sub

The following error message pop up after callaDLL run.
runtime error '453'
Can't find DLL entry point fnTest in test

I know that thet function name is case sensitive and has
been checked.

Please help the beginner.

Thanks

Enoch
 
Hi there,

It would seem that you've wandered into the wrong room. We all do VB here
and (mostly) quake in our boots when faced with C++. ;-)

There's a better room to go to somewhere down the hall, as it were. One of
the guys will tell you which it is in the morning.

DF
 
Back
Top