1. 程式人生 > >MFC DLL 的初始化入口函式:

MFC DLL 的初始化入口函式:

#pragma once

#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"  // main symbols

class CSpeechApp : public CWinApp
{
public:
 CSpeechApp();

public:
 virtual BOOL InitInstance();
 DECLARE_MESSAGE_MAP()
};

// Speech.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "Speech.h"
#include "PlugIn.h"
#include "afxdialogex.h"
#include "SpeechSetting.h"

BEGIN_MESSAGE_MAP(CSpeechApp, CWinApp)
END_MESSAGE_MAP()


CSpeechApp::CSpeechApp()
{
}

C++ 的初始化入口函式:

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

BOOL APIENTRY DllMain( HMODULE 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;
}

如果不加則在初始話彈出對話方塊時總是不能載入成功!