Files
2026-02-13 14:34:15 +08:00

52 lines
1.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ServerControl.cpp : 定义 DLL 的初始化例程。
//
#include "stdafx.h"
#include <afxdllx.h>
#include "ServerControlItemSink.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
static AFX_EXTENSION_MODULE ServerControlDLL = { NULL, NULL };
extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// 如果使用 lpReserved请将此移除
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("ServerControl.DLL 正在初始化!\n");
if (!AfxInitExtensionModule(ServerControlDLL, hInstance)) return 0;
new CDynLinkLibrary(ServerControlDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("ServerControl.DLL 正在终止!\n");
AfxTermExtensionModule(ServerControlDLL);
}
return 1; // 确定
}
//建立对象函数
extern "C" __declspec(dllexport) void * __cdecl CreateServerControl()
{
//建立对象
CServerControlItemSink * pServerControl = NULL;
try
{
pServerControl = new CServerControlItemSink();
if (pServerControl == NULL)
throw TEXT("创建失败");
return pServerControl;
}
catch (...) {}
//清理对象
SafeDelete(pServerControl);
return NULL;
}