- Timestamp:
- Jan 30, 2017 6:38:26 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/win/svcmain.cpp
r64160 r65525 144 144 END_OBJECT_MAP() 145 145 146 CExeModule _Module;146 CExeModule* g_pModule = NULL; 147 147 HWND g_hMainWindow = NULL; 148 148 HINSTANCE g_hInstance = NULL; … … 191 191 case WM_QUERYENDSESSION: 192 192 { 193 rc = !_Module.HasActiveConnection(); 194 if (!rc) 195 { 196 /* place the VBoxSVC into system shutdown list */ 197 ShutdownBlockReasonCreateAPI(hwnd, L"Has active connections."); 198 /* decrease a latency of MonitorShutdown loop */ 199 ASMAtomicXchgU32(&dwTimeOut, 100); 200 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n", 201 _Module.bActivity, _Module.GetLockCount())); 193 if (g_pModule) 194 { 195 rc = !g_pModule->HasActiveConnection(); 196 if (!rc) 197 { 198 /* place the VBoxSVC into system shutdown list */ 199 ShutdownBlockReasonCreateAPI(hwnd, L"Has active connections."); 200 /* decrease a latency of MonitorShutdown loop */ 201 ASMAtomicXchgU32(&dwTimeOut, 100); 202 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n", 203 g_pModule->bActivity, g_pModule->GetLockCount())); 204 } 205 } 206 else 207 { 208 Assert(g_pModule); 209 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: Error: g_pModule is NULL")); 202 210 } 203 211 } break; … … 500 508 int nRet = 0; 501 509 HRESULT hRes = com::Initialize(false /*fGui*/, fRun /*fAutoRegUpdate*/); 502 503 510 _ASSERTE(SUCCEEDED(hRes)); 504 _Module.Init(ObjectMap, hInstance, &LIBID_VirtualBox); 505 _Module.dwThreadID = GetCurrentThreadId(); 511 512 g_pModule = new CExeModule(); 513 if(g_pModule == NULL) 514 return RTMsgErrorExit(RTEXITCODE_FAILURE, "not enough memory to create ExeModule."); 515 g_pModule->Init(ObjectMap, hInstance, &LIBID_VirtualBox); 516 g_pModule->dwThreadID = GetCurrentThreadId(); 506 517 507 518 if (!fRun) … … 510 521 if (fUnregister) 511 522 { 512 _Module.UpdateRegistryFromResource(IDR_VIRTUALBOX, FALSE);513 nRet = _Module.UnregisterServer(TRUE);523 g_pModule->UpdateRegistryFromResource(IDR_VIRTUALBOX, FALSE); 524 nRet = g_pModule->UnregisterServer(TRUE); 514 525 } 515 526 if (fRegister) 516 527 { 517 _Module.UpdateRegistryFromResource(IDR_VIRTUALBOX, TRUE);518 nRet = _Module.RegisterServer(TRUE);528 g_pModule->UpdateRegistryFromResource(IDR_VIRTUALBOX, TRUE); 529 nRet = g_pModule->RegisterServer(TRUE); 519 530 } 520 531 #endif … … 543 554 else 544 555 { 545 _Module.StartMonitor();556 g_pModule->StartMonitor(); 546 557 #if _WIN32_WINNT >= 0x0400 547 hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);558 hRes = g_pModule->RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED); 548 559 _ASSERTE(SUCCEEDED(hRes)); 549 560 hRes = CoResumeClassObjects(); … … 571 582 DestroyMainWindow(); 572 583 573 _Module.RevokeClassObjects();574 } 575 576 _Module.Term();584 g_pModule->RevokeClassObjects(); 585 } 586 587 g_pModule->Term(); 577 588 578 589 com::Shutdown(); 590 591 if(g_pModule) 592 delete g_pModule; 593 g_pModule = NULL; 579 594 580 595 Log(("SVCMAIN: Returning, COM server process ends.\n"));
Note:
See TracChangeset
for help on using the changeset viewer.