// // Server unregistration // STDAPI DllUnregisterServer() { HRESULT hr = UnregisterServer(CLSID_CoCOMServerOptional, g_szVerIndProgIDOptional, g_szProgIDOptional, LIBID_AutoHotkey) ; hr = UnregisterServer(CLSID_CoCOMServer, g_szVerIndProgID, g_szProgID, LIBID_AutoHotkey) ; if (SUCCEEDED(hr)) { UnRegisterTypeLib( g_hInstance, NULL); } return hr; }
/*! install service -i uninstall service -u run as service -runas service run as session -runas session -parent n check and install -c run hook -runas hook -parent n */ bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode) throw() { if (!CAtlServiceModuleT< CWinRobotHostModule, IDS_SERVICENAME >::ParseCommandLine(lpCmdLine, pnRetCode)) return false; TCHAR szTokens[] = _T("-/"); *pnRetCode = S_OK; LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens); while (lpszToken != NULL) { if (WordCmpI(lpszToken, _T("I"))==0) // install { *pnRetCode = RegisterAppId(true); if (SUCCEEDED(*pnRetCode)) *pnRetCode = RegisterServer(TRUE); return false; } else if (WordCmpI(lpszToken, _T("U"))==0)// uninstall { *pnRetCode = UnregisterServer(TRUE); if (SUCCEEDED(*pnRetCode)) *pnRetCode = UnregisterAppId(); return false; } else if (WordCmpI(lpszToken, _T("runas"))==0) { lpszToken = FindOneOf(lpszToken, _T(" ")); if (WordCmpI(lpszToken, _T("service")) == 0) // run as service { return true; } else if(WordCmpI(lpszToken, _T("session")) == 0) // run as session { lpszToken = FindOneOf(lpszToken, _T("-/")); if(WordCmpI(lpszToken, _T("parent")) == 0) { lpszToken = FindOneOf(lpszToken, _T(" ")); CSessionHost host(_tcstoul(lpszToken,0,10)); host.Run(); host.WaitThreadEnd(); } } else if(WordCmpI(lpszToken, _T("hook")) == 0) // run as session { lpszToken = FindOneOf(lpszToken, _T("-/")); if(WordCmpI(lpszToken, _T("parent")) == 0) { lpszToken = FindOneOf(lpszToken, _T(" ")); CHookHost host(_tcstoul(lpszToken,0,10)); host.Run(); } } return false; } lpszToken = FindOneOf(lpszToken, szTokens); } return true; }
STDAPI DllUnregisterServer() { // Register the desk band object. if(FAILED(UnregisterServer(CLSID_NET_PROFILER, TEXT("Hook Net")))) return SELFREG_E_CLASS; return S_OK; }
/***************************************************************************** * DllUnregisterServer() ***************************************************************************** */ STDAPI DllUnregisterServer ( void ) { _DbgPrintF(DEBUGLVL_VERBOSE,("[DllUnregisterServer]")); HRESULT hr = UnregisterServer(NULL); return hr; }
// // Server unregistration // STDAPI DllUnregisterServer() { const HMODULE hModule = ::GetModuleHandle(nullptr); HRESULT hr = UnregisterServer(CLSID_GitWCRev, L"GitWCRev.object", L"GitWCRev.object.1", LIBID_LibGitWCRev) ; if (SUCCEEDED(hr)) UnRegisterTypeLib(hModule, nullptr); return hr; }
void CRakMasterServer::ProcessRegistrations() { std::map<uint64, TServerDetails*>::iterator Current = m_mRegisteredServers.begin(); std::map<uint64, TServerDetails*>::iterator End = m_mRegisteredServers.end(); m_CompiledServerList.Reset(); m_CompiledServerList.Write((uchar)MessageId_ServerList); std::vector<uint64> aUnregisterList; std::string sIp = "";; while (Current != End) { TServerDetails* tpServerDetails = (*Current).second; tpServerDetails->fUnregisterTimer -= CLOCK.GetDeltaTick(); if (tpServerDetails->fUnregisterTimer < 0.0f) { aUnregisterList.push_back(tpServerDetails->tGuid.g); } else { sIp = tpServerDetails->tAddress.ToString(); m_CompiledServerList.Write(sIp.c_str(), sIp.length()); m_CompiledServerList.Write("&", 1); } ++ Current; } //LOG_MESSAGE("Proccess (%d) registrees", m_mRegisteredServers.size()); for (uint i = 0; i < aUnregisterList.size(); ++ i) { UnregisterServer(aUnregisterList[i]); LOG_MESSAGE("Unregistered a server"); } }
void DirectoryServer::ProcessUnregisterServer(INetPacket* thePacket) { // The application ID to register this server under typeAppID anAppID; // The server ID (title) to match against typeNetAlias anNetAlias; // Retrieve the application ID from the RegisterServer message *thePacket >> anAppID; // Retrieve the server ID (title) *thePacket >> anNetAlias; // Now attempt to unregister this server by server ID (title) UnregisterServer(anAppID, anNetAlias); }
BOOL CGameServDlg::StopServer() { // Unregister the server if necessary... if (m_bRunning) { UnregisterServer(); } // Terminate the GameSpy manager... m_GameSpyMgr.Term(); // Flag that we are done... m_bRunning = FALSE; // Wait for the thread to stop... if (m_hThread) { Sleep(0); DWORD dwRet = WaitForSingleObject(m_hThread, 1000); Sleep(0); if (dwRet == WAIT_OBJECT_0) { CloseHandle(m_hThread); } else { TerminateThread(m_hThread, 0); } m_hThread = NULL; } // All done... return(TRUE); }
HRESULT CShellNSE::UnregisterProperties(HINSTANCE hInst, GUID guid) { TCHAR szCLSID[MAX_PATH]; TCHAR szSubKey[MAX_PATH]; CString::GuidToString(guid, szCLSID, ARRAYSIZE(szCLSID)); wsprintf(szSubKey, TEXT("CLSID\\%s\\ShellEx\\PropertySheetHandlers\\FolderProperties"), szCLSID); RegDeleteKey(regProperties.hRootKey, szSubKey); wsprintf(szSubKey, TEXT("CLSID\\%s\\ShellEx\\PropertySheetHandlers"), szCLSID); RegDeleteKey(regProperties.hRootKey, szSubKey); wsprintf(szSubKey, TEXT("CLSID\\%s\\ShellEx"), szCLSID); RegDeleteKey(regProperties.hRootKey, szSubKey); UnregisterServer(hInst, guid); return S_OK; }
/***************************************************************************** * DllInstall() ***************************************************************************** */ STDAPI DllInstall ( IN BOOL Install, IN LPCWSTR CmdLine ) { _DbgPrintF(DEBUGLVL_VERBOSE,("[DllInstall]")); HRESULT hr = S_OK; _DbgPrintF(DEBUGLVL_VERBOSE,("[DllInstall] - Install : %d, CmdLine : %ws", Install, CmdLine)); if (CmdLine) { PWCHAR DevicePathW = wcsstr(CmdLine, L"/DevPath"); if (DevicePathW) { DevicePathW += wcslen(L"/DevPath")+1; TCHAR SymbolicLink[MAX_PATH]; _stprintf(SymbolicLink, "%ws", DevicePathW); _DbgPrintF(DEBUGLVL_BLAB,("[DllInstall] - SymbolicLink : %s", SymbolicLink)); if (Install) { hr = RegisterServer(SymbolicLink); } else { hr = UnregisterServer(SymbolicLink); } } } return hr; }
//--------------------------------------------------------------------------- // DllUnregisterServer //--------------------------------------------------------------------------- STDAPI DllUnregisterServer(void) { return (UnregisterServer(CLSID_ShellExtension, szShellExtensionTitle) ? S_OK : E_FAIL); }
HRESULT __stdcall UnRegisterCompent(const GUID& guid,LPCWSTR prog_id,LPCWSTR ver) { return UnregisterServer(guid, prog_id, ver); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nCmdShow*/) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // TODO: 여기에 코드를 입력합니다. g_idMainThread = ::GetCurrentThreadId(); // 전역 문자열을 초기화합니다. LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); if (FAILED(::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { ::MessageBox(NULL, L"COM 초기화 에러.", NULL, MB_ICONERROR|MB_OK); return 0; } //HRESULT hr = ::CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); //_ASSERT(SUCCEEDED(hr)); if (lpCmdLine && ((_wcsicmp(lpCmdLine, L"-Embedding") == 0) || (_wcsicmp(lpCmdLine, L"/Embedding") == 0) || (_wcsicmp(lpCmdLine, L"- Embedding") == 0) || (_wcsicmp(lpCmdLine, L"/ Embedding") == 0))) { // ROT 등록 RegisterClassObject(); } else { if (lpCmdLine && ((_wcsicmp(lpCmdLine, L"-RegServer") == 0) || (_wcsicmp(lpCmdLine, L"/RegServer") == 0) || (_wcsicmp(lpCmdLine, L"- RegServer") == 0) || (_wcsicmp(lpCmdLine, L"/ RegServer") == 0))) { RegisterServer(); return 0; } else if (lpCmdLine &&((_wcsicmp(lpCmdLine, L"-UnregServer") == 0) || (_wcsicmp(lpCmdLine, L"/UnregServer") == 0) || (_wcsicmp(lpCmdLine, L"- UnregServer") == 0) || (_wcsicmp(lpCmdLine, L"/ UnregServer") == 0))) { UnregisterServer(); return 0; } else { switch (::MessageBox(NULL, L"HbgServ 컴포넌트를 등록할까요?\n\n- 예(등록)\n- 아니오(등록 해제)", NULL, MB_ICONQUESTION|MB_YESNOCANCEL)) { case IDYES: RegisterServer(); return 0; break; case IDNO: UnregisterServer(); return 0; break; case IDCANCEL: return 0; break; } } } // 기본 메시지 루프입니다. MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } // ROT 해제 RevokeClassObject(); ::CoUninitialize(); return (int) msg.wParam; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { bool bExit = false; CoInitialize(NULL); // To know which thread has to receive the right message when closing CFactory::s_dwThreadID = ::GetCurrentThreadId(); // Read the command line. // This commandline routine is straight from the Inside COM book char szTokens[] = "-/" ; char* szToken = strtok(lpCmdLine, szTokens) ; while (szToken != NULL) { if (_stricmp(szToken, "UnregServer") == 0) { UnregisterServer( CLSID_SDWSourceContainer, g_szVerIndProgID, g_szProgID) ; // We are done, so exit. bExit = TRUE ; } else if (_stricmp(szToken, "RegServer") == 0) { // thanks to the _OUTPROC_SERVER_ define in the settings // the Registerserver() function is creating a LocalServer32 key // instead of InprocServer32 RegisterServer( hInstance, CLSID_SDWSourceContainer, g_szFriendlyName, g_szVerIndProgID, g_szProgID ) ; // We are done, so exit. bExit = TRUE ; } szToken = strtok(NULL, szTokens) ; } // Create the factory CFactory * pIFact = new CFactory(); // A cookie to store the reg info DWORD dwRegCookie; // register the Factory, so COM knows how to create an SDWSourceContainer CoRegisterClassObject( CLSID_SDWSourceContainer, static_cast<IUnknown*> (pIFact), CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &dwRegCookie ); // start an messagepump if ( !bExit ) { MSG msg ; // GetMessage only gives back a 0 if WM_QUIT is send while (::GetMessage(&msg, 0, 0, 0)) { ::DispatchMessage(&msg) ; } } // release the factory pIFact->Release(); // Unregister the ClassFactory CoRevokeClassObject(dwRegCookie); CoUninitialize(); return 0; }
static void MasterServer_OnChange(void) { UnregisterServer(); RegisterServer(); }
static void ServerName_OnChange(void) { UnregisterServer(); RegisterServer(); }
//--------------------------------------------------------------------------- // DllUnregisterServer //--------------------------------------------------------------------------- STDAPI DllUnregisterServer(void) { return (UnregisterServer() ? S_OK : E_FAIL); }
//--------------------------------------------------------------------------- // RegisterServer // Create registry entries and setup the shell extension //--------------------------------------------------------------------------- BOOL RegisterServer() { int i; HKEY hKey; LRESULT lResult; DWORD dwDisp; TCHAR szSubKey[MAX_PATH]; TCHAR szModule[MAX_PATH]; TCHAR szDefaultPath[MAX_PATH]; GetModuleFileName(_hModule, szDefaultPath, MAX_PATH); TCHAR* pDest = StrRChr(szDefaultPath, NULL, TEXT('\\')); pDest++; pDest[0] = 0; lstrcat(szDefaultPath, szNppName); if (!CheckNpp(szDefaultPath)) { MsgBoxError(TEXT("To register the Notepad++ shell extension properly,\r\nplace NppShell.dll in the same directory as the Notepad++ executable.")); //return FALSE; } //get this app's path and file name GetModuleFileName(_hModule, szModule, MAX_PATH); static DOREGSTRUCT ClsidEntries[] = { {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, REG_SZ, szShellExtensionTitle}, {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, REG_SZ, szModule}, {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), TEXT("ThreadingModel"), REG_SZ, TEXT("Apartment")}, //Settings // Context menu {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Title"), REG_SZ, szDefaultMenutext}, {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Path"), REG_SZ, szDefaultPath}, {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Custom"), REG_SZ, szDefaultCustomcommand}, {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("ShowIcon"), REG_DWORD, (LPTSTR)&showIcon}, // Icon {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Dynamic"), REG_DWORD, (LPTSTR)&isDynamic}, {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Maxtext"), REG_DWORD, (LPTSTR)&maxText}, //Registration // Context menu {HKEY_CLASSES_ROOT, szShellExtensionKey, NULL, REG_SZ, szGUID}, // Icon //{HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), NULL, REG_SZ, szGUID}, {NULL, NULL, NULL, REG_SZ, NULL} }; // First clear any old entries UnregisterServer(); // Register the CLSID entries for(i = 0; ClsidEntries[i].hRootKey; i++) { wsprintf(szSubKey, ClsidEntries[i].szSubKey, szGUID); lResult = RegCreateKeyEx(ClsidEntries[i].hRootKey, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp); if (NOERROR == lResult) { TCHAR szData[MAX_PATH]; // If necessary, create the value string if (ClsidEntries[i].type == REG_SZ) { wsprintf(szData, ClsidEntries[i].szData, szModule); lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR)); } else { lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)ClsidEntries[i].szData, sizeof(DWORD)); } RegCloseKey(hKey); } else return FALSE; } return TRUE; }
/* Scan the command line, extract arguments and init variables */ int scan_cmdline(int argc, char **argv) { int cnt; char *p; char msg[80]; int import = 0; char *rom = NULL; char *tib = NULL; char *sav = NULL; char *fn = NULL; //for(cnt = 0; cnt < argc; cnt++) // fprintf(stdout, "%i: [%s]\n", cnt, argv[cnt]); /* Parses list of arguments */ for(cnt=1; cnt<argc; cnt++) { p = argv[cnt]; #ifdef __WIN32__ if(!stricmp(p, "/RegServer") || !stricmp(p, "-RegServer") || !stricmp(p, "--RegServer")) { char *p; ITypeLib *tlb; char szModule[512]; wchar_t tlbname[512]; HMODULE hModule = GetModuleHandle(NULL); DWORD dwResult = GetModuleFileName(hModule, szModule, sizeof(szModule)); if (!dwResult) exit(1); p = szModule + strlen(szModule) - 4; if (stricmp(p,".exe")) exit(1); strcpy(++p,"tlb"); mbstowcs(tlbname, szModule, strlen(szModule)+1); if (RegisterServer(&CLSID_TiEmuOLE, "TiEmu OLE Interface", "TiEmu.TiEmuOLE", "TiEmu.TiEmuOLE.1", NULL) || LoadTypeLib(tlbname, &tlb)) exit(1); else { if (RegisterTypeLib(tlb, tlbname, NULL)) { tlb->lpVtbl->Release(tlb); exit(1); } else { tlb->lpVtbl->Release(tlb); fprintf(stdout, "TiEmu OLE Interface successfully registered."); exit(0); } } } if(!stricmp(p, "/UnregServer") || !stricmp(p, "-UnregServer") || !stricmp(p, "--UnregServer")) { if (UnregisterServer(&CLSID_TiEmuOLE, "TiEmu.TiEmuOLE", "TiEmu.TiEmuOLE.1") || UnRegisterTypeLib(&LIBID_TiEmuOLELib, 1, 0, 0, SYS_WIN32)) exit(1); else { fprintf(stdout, "TiEmu OLE Interface successfully unregistered."); exit(0); } } if(!stricmp(p, "/Embedding") || !stricmp(p, "-Embedding") || !stricmp(p, "--Embedding")) { // VB runs it with this option. continue; } #endif if(*p == '-') { // a long option (like --help) p++; } else { fn = g_strdup(p); // a filename //g_free(params.rom_file); //params.rom_file = g_strdup(p); } strcpy(msg, p); if(strexact(msg, "-import")) import = !0; if(strstr(msg, "rom=")) rom = g_strdup(msg + 4); if(strstr(msg, "tib=")) tib = g_strdup(msg + 4); if(strstr(msg, "sav=")) sav = g_strdup(msg + 4); if(strstr(msg, "send=")) file_to_send = g_strdup(msg + 5); if(strexact(msg, "-help") || strexact(msg, "h")) help(); if(strexact(msg, "-version") || strexact(msg, "v")) exit(0); } /* */ if(fn && ti68k_is_a_rom_file(fn)) rom = fn; else if(fn && ti68k_is_a_tib_file(fn)) tib = fn; else if(fn && ti68k_is_a_sav_file(fn)) sav = fn; /* And process them */ if(rom && ti68k_is_a_rom_file(rom)) { gchar *dstname; int err = ti68k_convert_rom_to_image(rom, inst_paths.img_dir, &dstname); if(err) { tiemu_err(err, NULL); exit(-1); } if(import) exit(0); g_free(params.rom_file); params.rom_file = dstname; g_free(params.sav_file); params.sav_file = g_strdup(""); } if(tib && ti68k_is_a_tib_file(tib)) { gchar *dstname; int err = ti68k_convert_tib_to_image(tib, inst_paths.img_dir, &dstname, -1); if(err) { tiemu_err(err, NULL); exit(-1); } if(import) exit(0); g_free(params.rom_file); params.rom_file = dstname; g_free(params.sav_file); params.sav_file = g_strdup(""); } if(sav && !fn) // for compatibility { g_free(params.sav_file); params.sav_file = g_strdup(sav); } if(sav && ti68k_is_a_sav_file(sav) && fn) { gchar *rf, *tf; ti68k_state_parse(sav, &rf, &tf); if(!ti68k_is_a_img_file(rf)) return 0; g_free(params.rom_file); params.rom_file = rf; g_free(params.tib_file); params.tib_file = tf; g_free(params.sav_file); params.sav_file = g_strdup(sav); } return 0; }