1BOOL RegisterOcx(LPCTSTR OcxFileName)
2{
3 LPCTSTR pszDllName = OcxFileName ; //ActiveX控件的路径及文件名
4 HINSTANCE hLib = LoadLibrary(pszDllName); //装载ActiveX控件
5 if (hLib < (HINSTANCE)HINSTANCE_ERROR)
6 {
7 return FALSE ;
8 }
9 FARPROC lpDllEntryPoint;
10 lpDllEntryPoint =GetProcAddress(hLib,_T("DllRegisterServer")); //获取注册函数DllRegisterServer地址
11
12 if(lpDllEntryPoint!=NULL) //调用注册函数DllRegisterServer
13 {
14 if(FAILED((*lpDllEntryPoint)()))
15 {
16 FreeLibrary(hLib);
17 return FALSE ;
18 }
19 return TRUE ;
20 }
21 else
22 return FALSE ;
23}
24
25
26BOOL UnRegisterOcx(LPCTSTR OcxFileName)
27{
28 LPCTSTR pszDllName = OcxFileName ; //ActiveX控件的路径及文件名
29 HINSTANCE hLib = LoadLibrary(pszDllName); //装载ActiveX控件
30 if (hLib < (HINSTANCE)HINSTANCE_ERROR)
31 {
32 return FALSE ;
33 }
34 FARPROC lpDllEntryPoint;
35 lpDllEntryPoint = GetProcAddress(hLib,_T("DllUnregisterServer")); //获取注册函数DllUnregisterServer地址
36
37 if(lpDllEntryPoint!=NULL) //调用注册函数DllUnregisterServer
38 {
39 if(FAILED((*lpDllEntryPoint)()))
40 {
41 FreeLibrary(hLib);
42 return FALSE ;
43 }
44 return TRUE ;
45 }
46 else
47 return FALSE ;
48}
49
50
51bool CMsgGathorDlg::IsReg()
52{
53 HKEY hKey;
54 BOOL bPresent;
55 TCHAR szPath[_MAX_PATH];
56 DWORD dwRegType;
57 DWORD cbData = sizeof szPath * sizeof TCHAR;
58
59 hKey = NULL;
60 bPresent = FALSE;
61 ::RegOpenKey(HKEY_CLASSES_ROOT, _T("CLSID\\{4CAD92F0-D7C4-11D0-BCF7-00C04FC2FB86}\\InprocServer32"), &hKey);
62 if(hKey)
63 {
64 HANDLE hfile;
65
66 szPath[0] = 0;
67 ::RegQueryValueEx(hKey, NULL, NULL, &dwRegType, (LPBYTE)szPath, &cbData);
68 ::RegCloseKey(hKey);
69
70 hfile = ::CreateFile(szPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
71 if(INVALID_HANDLE_VALUE != hfile)
72 {
73 bPresent = TRUE;
74 ::CloseHandle(hfile);
75 }
76 }
77
78 return bPresent;
79}
80
81
82
83bool CMsgGathorDlg::IsReg()
84{
85 HKEY hKey;
86 BOOL bPresent;
87 TCHAR szPath[_MAX_PATH];
88 DWORD dwRegType;
89 DWORD cbData = sizeof szPath * sizeof TCHAR;
90
91 hKey = NULL;
92 bPresent = FALSE;
93 ::RegOpenKey(HKEY_CLASSES_ROOT, _T("CLSID\\{4CAD92F0-D7C4-11D0-BCF7-00C04FC2FB86}\\InprocServer32"), &hKey);
94 if(hKey)
95 {
96 HANDLE hfile;
97
98 szPath[0] = 0;
99 ::RegQueryValueEx(hKey, NULL, NULL, &dwRegType, (LPBYTE)szPath, &cbData);
100 ::RegCloseKey(hKey);
101
102 hfile = ::CreateFile(szPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
103 if(INVALID_HANDLE_VALUE != hfile)
104 {
105 bPresent = TRUE;
106 ::CloseHandle(hfile);
107 }
108 }
109
110 return bPresent;
111}
112
2{
3 LPCTSTR pszDllName = OcxFileName ; //ActiveX控件的路径及文件名
4 HINSTANCE hLib = LoadLibrary(pszDllName); //装载ActiveX控件
5 if (hLib < (HINSTANCE)HINSTANCE_ERROR)
6 {
7 return FALSE ;
8 }
9 FARPROC lpDllEntryPoint;
10 lpDllEntryPoint =GetProcAddress(hLib,_T("DllRegisterServer")); //获取注册函数DllRegisterServer地址
11
12 if(lpDllEntryPoint!=NULL) //调用注册函数DllRegisterServer
13 {
14 if(FAILED((*lpDllEntryPoint)()))
15 {
16 FreeLibrary(hLib);
17 return FALSE ;
18 }
19 return TRUE ;
20 }
21 else
22 return FALSE ;
23}
24
25
26BOOL UnRegisterOcx(LPCTSTR OcxFileName)
27{
28 LPCTSTR pszDllName = OcxFileName ; //ActiveX控件的路径及文件名
29 HINSTANCE hLib = LoadLibrary(pszDllName); //装载ActiveX控件
30 if (hLib < (HINSTANCE)HINSTANCE_ERROR)
31 {
32 return FALSE ;
33 }
34 FARPROC lpDllEntryPoint;
35 lpDllEntryPoint = GetProcAddress(hLib,_T("DllUnregisterServer")); //获取注册函数DllUnregisterServer地址
36
37 if(lpDllEntryPoint!=NULL) //调用注册函数DllUnregisterServer
38 {
39 if(FAILED((*lpDllEntryPoint)()))
40 {
41 FreeLibrary(hLib);
42 return FALSE ;
43 }
44 return TRUE ;
45 }
46 else
47 return FALSE ;
48}
49
50
51bool CMsgGathorDlg::IsReg()
52{
53 HKEY hKey;
54 BOOL bPresent;
55 TCHAR szPath[_MAX_PATH];
56 DWORD dwRegType;
57 DWORD cbData = sizeof szPath * sizeof TCHAR;
58
59 hKey = NULL;
60 bPresent = FALSE;
61 ::RegOpenKey(HKEY_CLASSES_ROOT, _T("CLSID\\{4CAD92F0-D7C4-11D0-BCF7-00C04FC2FB86}\\InprocServer32"), &hKey);
62 if(hKey)
63 {
64 HANDLE hfile;
65
66 szPath[0] = 0;
67 ::RegQueryValueEx(hKey, NULL, NULL, &dwRegType, (LPBYTE)szPath, &cbData);
68 ::RegCloseKey(hKey);
69
70 hfile = ::CreateFile(szPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
71 if(INVALID_HANDLE_VALUE != hfile)
72 {
73 bPresent = TRUE;
74 ::CloseHandle(hfile);
75 }
76 }
77
78 return bPresent;
79}
80
81
82
83bool CMsgGathorDlg::IsReg()
84{
85 HKEY hKey;
86 BOOL bPresent;
87 TCHAR szPath[_MAX_PATH];
88 DWORD dwRegType;
89 DWORD cbData = sizeof szPath * sizeof TCHAR;
90
91 hKey = NULL;
92 bPresent = FALSE;
93 ::RegOpenKey(HKEY_CLASSES_ROOT, _T("CLSID\\{4CAD92F0-D7C4-11D0-BCF7-00C04FC2FB86}\\InprocServer32"), &hKey);
94 if(hKey)
95 {
96 HANDLE hfile;
97
98 szPath[0] = 0;
99 ::RegQueryValueEx(hKey, NULL, NULL, &dwRegType, (LPBYTE)szPath, &cbData);
100 ::RegCloseKey(hKey);
101
102 hfile = ::CreateFile(szPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
103 if(INVALID_HANDLE_VALUE != hfile)
104 {
105 bPresent = TRUE;
106 ::CloseHandle(hfile);
107 }
108 }
109
110 return bPresent;
111}
112