在程序中注冊(cè)ActiveX控件(.OCX)的函數(shù)
BOOL RegisterOcx(LPCTSTR OcxFileName)
{
LPCTSTR pszDllName = OcxFileName ; //ActiveX控件的路徑及文件名
HINSTANCE hLib = LoadLibrary(pszDllName); //裝載ActiveX控件
if (hLib < (HINSTANCE)HINSTANCE_ERROR)
{
return FALSE ;
}
FARPROC lpDllEntryPoint;
lpDllEntryPoint = GetProcAddress(hLib,_T("DllRegisterServer")); //獲取注冊(cè)函數(shù)DllRegisterServer地址
if(lpDllEntryPoint!=NULL) //調(diào)用注冊(cè)函數(shù)DllRegisterServer
{
if(FAILED((*lpDllEntryPoint)()))
{
FreeLibrary(hLib);
return FALSE ;
}
return TRUE ;
}
else
return FALSE ;
}
//----------------------------------
在程序中注銷ActiveX控件(.OCX)的函數(shù)
BOOL UnRegisterOcx(LPCTSTR OcxFileName)
{
LPCTSTR pszDllName = OcxFileName ; //ActiveX控件的路徑及文件名
HINSTANCE hLib = LoadLibrary(pszDllName); //裝載ActiveX控件
if (hLib < (HINSTANCE)HINSTANCE_ERROR)
{
return FALSE ;
}
FARPROC lpDllEntryPoint;
lpDllEntryPoint = GetProcAddress(hLib,_T("DllUnregisterServer")); //獲取注冊(cè)函數(shù)DllUnregisterServer地址
if(lpDllEntryPoint!=NULL) //調(diào)用注冊(cè)函數(shù)DllUnregisterServer
{
if(FAILED((*lpDllEntryPoint)()))
{
FreeLibrary(hLib);
return FALSE ;
}
return TRUE ;
}
else
return FALSE ;
}
|
溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!