⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mailunit.cpp

📁 使用OPCST开发的进程内OPCDA服务器(C++Builder)
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------------------------------------------
//   Important note about DLL memory management when your DLL uses the
//   static version of the RunTime Library:
//
//   If your DLL exports any functions that pass String objects (or structs/
//   classes containing nested Strings) as parameter or function results,
//   you will need to add the library MEMMGR.LIB to both the DLL project and
//   any other projects that use the DLL.  You will also need to use MEMMGR.LIB
//   if any other projects which use the DLL will be performing new or delete
//   operations on any non-TObject-derived classes which are exported from the
//   DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
//   EXE's to use the BORLNDMM.DLL as their memory manager.  In these cases,
//   the file BORLNDMM.DLL should be deployed along with your DLL.
//
//   To avoid using BORLNDMM.DLL, pass string information using "char *" or
//   ShortString parameters.
//
//   If your DLL uses the dynamic version of the RTL, you do not need to
//   explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------

#pragma argsused


#include "opcst_x.h"

extern HINSTANCE hInstance;//模块实例

//标记已加载设备标记
static bool bCalled = false;


int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
    switch (reason)
	{
	case DLL_PROCESS_ATTACH:
		{
			InitDeviceBuffer();

			hInstance = hinst;

			InitParm();

			InitOPCServer(hInstance, &OPCServerInfo ,
				&OPCRegInfo,  &VendorInfo,ReadVariant,WriteVariant);

			break;
		}
	case DLL_THREAD_ATTACH://DLL在加载过程中要CALL多次,添加Tag操作只需一次
		break;
	case DLL_THREAD_DETACH:
		break;
	case DLL_PROCESS_DETACH:
		break;
    }
    return TRUE;

}
//---------------------------------------------------------------------------

/////进程内组件标准函数
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
{
	HRESULT hr;
	hr = DLL_GetClassObject(rclsid, riid, ppvOut);
	if(SUCCEEDED(hr))
	{
		if(!bCalled)
		{
			LoadDeviceTag();
			bCalled = true;
		}
	}
	return hr;
}

STDAPI  DllCanUnloadNow(void)
{
	return DLL_CanUnloadNow();
}

STDAPI DllRegisterServer(void)
{
	return DLL_RegisterServer();
}

STDAPI DllUnregisterServer(void)
{
	return DLL_UnregisterServer();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -