STDAPI DllUnregisterServer(void) { AFX_MANAGE_STATE(_afxModuleAddrThis); // 删除控件初始化安全入口. HRESULT hr=UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing); if (FAILED(hr)) return hr; // 删除控件脚本安全入口 hr=UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting); if (FAILED(hr)) return hr; if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) return ResultFromScode(SELFREG_E_CLASS); return NOERROR; }
STDAPI DllUnregisterServer(void) { HRESULT hr; AFX_MANAGE_STATE(_afxModuleAddrThis); // Remove entries from the registry. hr=UnRegisterCLSIDInCategory(CLSID_SafeItem,CATID_SafeForInitializing); if (FAILED(hr)) { return hr; } hr=UnRegisterCLSIDInCategory(CLSID_SafeItem,CATID_SafeForScripting); if (FAILED(hr)) { return hr; } if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor)) { return ResultFromScode(SELFREG_E_TYPELIB);//lint !e835 } if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) { return ResultFromScode(SELFREG_E_CLASS); } return NOERROR; }//lint !e1788
STDAPI DllUnregisterServer(void) { HRESULT hr; // Remove entries from the registry. hr = UnRegisterCLSIDInCategory(CLSID_LHTMLActiveDocument, CATID_SafeForInitializing); if (FAILED(hr)) return hr; hr = UnRegisterCLSIDInCategory(CLSID_LHTMLActiveDocument, CATID_SafeForScripting); if (FAILED(hr)) return hr; return _Module.UnregisterServer(TRUE); }
// DllUnregisterServer - Removes entries from the system registry STDAPI DllUnregisterServer(void) { HRESULT hr; // HResult used by Safety Functions AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (!AfxOleUnregisterTypeLib(_tlid)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) return ResultFromScode(SELFREG_E_CLASS); // Remove entries from the registry. hr=UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing); if (FAILED(hr)) return hr; hr=UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting); if (FAILED(hr)) return hr; return NOERROR; }
// コマンドライン引数からCOMサーバー登録/削除を行う static int RegisterCOMServer(int &nRet, bool &bRun, bool &bAutomation, bool &bTray) { HRESULT hRes; TCHAR szTokens[] = _T("-/"); LPCTSTR lpszToken = _Module.FindOneOf(::GetCommandLine(), szTokens); while (lpszToken) { CString strToken = Misc::GetStrWord(lpszToken, &lpszToken); if (strToken.CompareNoCase(_T("UnregServer") ) == 0) { nRet = _Module.UnregisterServer(); nRet = UnRegisterCLSIDInCategory(CLSID_API, CATID_SafeForInitializing); if ( FAILED(nRet) ) return nRet; nRet = UnRegisterCLSIDInCategory(CLSID_API, CATID_SafeForScripting); if ( FAILED(nRet) ) return nRet; ::MessageBox(NULL, _T("COMサーバー削除しました。"), _T("unDonut"), 0); bRun = false; break; } else if (strToken.CompareNoCase(_T("RegServer") ) == 0) { nRet = _Module.RegisterServer(TRUE, &CLSID_API); if (nRet == S_OK) { // Mark the control as safe for initializing. hRes = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data"); if ( FAILED(hRes) ) return hRes; hRes = RegisterCLSIDInCategory(CLSID_API, CATID_SafeForInitializing); if ( FAILED(hRes) ) return hRes; // Mark the control as safe for scripting. hRes = CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable"); if ( FAILED(hRes) ) return hRes; hRes = RegisterCLSIDInCategory(CLSID_API, CATID_SafeForScripting); if ( FAILED(hRes) ) return hRes; ::MessageBox(NULL, _T("COMサーバー登録しました。"), _T("unDonut"), 0); } else ::MessageBox(NULL, _T("COMサーバー登録失敗しました。"), _T("unDonut"), 0); bRun = false; break; } else if (strToken.CompareNoCase(_T("Automation")) == 0 || (strToken.CompareNoCase(_T("Embedding" )) == 0) ) { bAutomation = true; break; #if 1 //+++ } else if (strToken.CompareNoCase(_T("tray") ) == 0) { bTray = true; break; #endif } lpszToken = _Module.FindOneOf(lpszToken, szTokens); } return S_OK; }