// 注册、卸载函数入口定义 typedef long (__stdcall *RegProc)(); // 注册ocx控件 BOOL RegisterOcx(CString sFile); // 卸载ocx控件 BOOL UnRegisterOcx(CString sFile); // ------------------------------------------------------------------ // 注册ocx控件 // add by jzh 2009-08-11 // ------------------------------------------------------------------ BOOL CommFunc::RegisterOcx(CString sFile) { BOOL bResult = FALSE; HMODULE hModule = LoadLibrary(sFile); //获得注册函数地址 RegProc DLLRegisterServer = (RegProc)GetProcAddress(hModule,"DllRegisterServer"); if (DLLRegisterServer != NULL) { long regResult = DLLRegisterServer(); bResult = (regResult == NOERROR); } FreeLibrary(hModule); return bResult; } // ------------------------------------------------------------------ // 卸载ocx控件 // add by jzh 2009-08-11 // ------------------------------------------------------------------ BOOL CommFunc::UnRegisterOcx(CString sFile) { BOOL bResult = FALSE; HMODULE hModule = LoadLibrary(sFile); //获得卸载函数地址 RegProc DLLUnregisterServer = (RegProc)GetProcAddress(hModule, "DllUnregisterServer"); if (DLLUnregisterServer != NULL) { long regResult = DLLUnregisterServer(); bResult = (regResult == NOERROR); } FreeLibrary(hModule); return bResult; }