This post originated from an RSS feed registered with .NET Buzz
by Frans Bouma.
Original Post: VC++ New DLL project humor
Feed Title: Frans Bouma's blog
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/fbouma/Rss.aspx
Feed Description: Generator.CreateCoolTool();
I started a little C++ Dll test project this morning and a good start for that is to fire up VS.NET 2003, create a new Win32 project and specify that it is a DLL.
VS.NET creates an initial .cpp file for you with some plumbing code. Here's the code it generated, no editing has been done on my part:
// TestLibrary.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "TestLibrary.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
TESTLIBRARY_API int nTestLibrary=0;
// This is an example of an exported function.
TESTLIBRARY_API int fnTestLibrary(void)
{
return 42;
}
// This is the constructor of a class that has been exported.
// see TestLibrary.h for the class definition
CTestLibrary::CTestLibrary()
{
return;
}
Now, take a good look at function 'fnTestLibrary'. . It's always good to see there are still developers with a good sense of humor around