// pch.cpp: 与预编译标头对应的源文件 #include "stdafx.h" // 当使用预编译的头时,需要使用此源文件,编译才能成功。 ////////////////////////////////////////////////////////////////////////// // 用例; HMODULE g_hdll = NULL; irc_IsAppRunning g_IsAppRunning = NULL; irc_StartIRApp g_StartIRApp = NULL; irc_CloseApp g_CloseApp = NULL; irc_Connect g_Connect = NULL; irc_loadSignalDataSet g_loadSignalDataSet = NULL; irc_getDeviceNames g_getDeviceNames = NULL; irc_getSignalsName g_getSignalsName = NULL; irc_sendSignal g_sendSignal = NULL; irc_sendSignals g_sendSignals = NULL; irc_sendRepeatsSignal g_sendRepeatsSignal = NULL; int g_nIRControl = 0; BOOL LoadLogLibarary() { if (g_hdll == NULL) { g_hdll = (HMODULE)LoadLibrary(_T("IRControl.dll")); if (!g_hdll) return FALSE; } g_sendRepeatsSignal = (irc_sendRepeatsSignal)GetProcAddress(g_hdll, "sendRepeatsSignal"); if (!g_sendRepeatsSignal) { FreeLogLibarary(); return FALSE; } g_sendSignals = (irc_sendSignals)GetProcAddress(g_hdll, "sendSignals"); if (!g_sendSignals) { FreeLogLibarary(); return FALSE; } g_sendSignal = (irc_sendSignal)GetProcAddress(g_hdll, "sendSignal"); if (!g_sendSignal) { FreeLogLibarary(); return FALSE; } g_loadSignalDataSet = (irc_loadSignalDataSet)GetProcAddress(g_hdll, "loadSignalDataSet"); if (!g_loadSignalDataSet) { FreeLogLibarary(); return FALSE; } g_IsAppRunning = (irc_IsAppRunning)GetProcAddress(g_hdll, "IsAppRunning"); if (!g_IsAppRunning) { FreeLogLibarary(); return FALSE; } g_StartIRApp = (irc_StartIRApp)GetProcAddress(g_hdll, "StartIRApp"); if (!g_StartIRApp) { FreeLogLibarary(); return FALSE; } g_CloseApp = (irc_CloseApp)GetProcAddress(g_hdll, "CloseApp"); if (!g_CloseApp) { FreeLogLibarary(); return FALSE; } g_getDeviceNames = (irc_getDeviceNames)GetProcAddress(g_hdll, "getDeviceNames"); if (!g_getDeviceNames) { FreeLogLibarary(); return FALSE; } g_Connect = (irc_Connect)GetProcAddress(g_hdll, "Connect"); if (!g_Connect) { FreeLogLibarary(); return FALSE; } g_getSignalsName = (irc_getSignalsName)GetProcAddress(g_hdll, "getSignalsName"); if (!g_getSignalsName) { FreeLogLibarary(); return FALSE; } // 导出全局变量; g_nIRControl = *(int*)GetProcAddress(g_hdll, "nIRControl"); if (!g_CloseApp) { FreeLogLibarary(); return FALSE; } return TRUE; } void FreeLogLibarary() { if (g_hdll) { if (FreeLibrary(g_hdll)) { g_hdll = NULL; g_IsAppRunning = NULL; g_StartIRApp = NULL; g_CloseApp = NULL; g_Connect = NULL; g_getDeviceNames = NULL; g_getSignalsName = NULL; g_loadSignalDataSet = NULL; g_sendSignal = NULL; g_sendSignals = NULL; g_sendRepeatsSignal = NULL; } } }