May 11, 2005

Creating a Win 32 Resource DLL

Use a 'Win32 Project' template from the 'Visual C++ Projects' list of project types. In the Wizard, select 'Application Settings'. In this tab sheet set the 'Application Type' to 'DLL' and 'Additional Options' to 'Empty Project'. Add the following as a source file called 'DllMain.cpp'
#define WIN32_LEAN_AND_MEAN
#include "windows.h"

//LPTSTR FileName = _T("AWin32Resources.dll");


BOOL WINAPI DllMain(
  HINSTANCE hinstDLL,  // handle to DLL module
  DWORD fdwReason,     // reason for calling function
  LPVOID lpReserved )  // reserved
{

  // Perform actions based on the reason for calling.
  switch( fdwReason )
  {
      case DLL_PROCESS_ATTACH:
   
   
       // Initialize once for each new process.
       // Return FALSE to fail DLL load.
          break;

      case DLL_THREAD_ATTACH:
       // Do thread-specific initialization.
          break;

      case DLL_THREAD_DETACH:
       // Do thread-specific cleanup.
          break;

      case DLL_PROCESS_DETACH:
  
       // Perform any necessary cleanup.
          break;
  }
  return TRUE;  // Successful DLL_PROCESS_ATTACH.
}
Add the resources as required.

No comments: