initialize COM on demand only

svn path=/trunk/; revision=18181
This commit is contained in:
Thomas Bluemel 2005-09-30 23:32:24 +00:00
parent 22f369c6b1
commit 0a52c57489
2 changed files with 17 additions and 19 deletions

View file

@ -27,6 +27,7 @@
#include <stdio.h>
#include <shellapi.h>
#include <objsel.h>
#include <objbase.h>
#include "main.h"
#include "regproc.h"
@ -680,6 +681,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
HRESULT hRet;
hRet = CoInitialize(NULL);
if (SUCCEEDED(hRet))
{
hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
if (SUCCEEDED(hRet))
{
@ -695,6 +699,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
FreeObjectPicker(ObjectPicker);
}
CoUninitialize();
}
return TRUE;
}
case ID_REGISTRY_DISCONNECTNETWORKREGISTRY:

View file

@ -30,7 +30,6 @@
#include <fcntl.h>
#include <aclui.h>
#include <cguid.h>
#include <objbase.h>
#include "main.h"
#include "hexedit.h"
@ -190,7 +189,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
{
MSG msg;
HACCEL hAccel;
HRESULT hComInit;
/*
int hCrt;
FILE *hf;
@ -224,9 +223,6 @@ int APIENTRY WinMain(HINSTANCE hInstance,
}
hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_REGEDIT);
/* initialize the COM library for the remote registry object picker dialog */
hComInit = CoInitialize(NULL);
/* Main message loop */
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)
@ -236,11 +232,6 @@ int APIENTRY WinMain(HINSTANCE hInstance,
}
}
if (SUCCEEDED(hComInit))
{
CoUninitialize();
}
ExitInstance(hInstance);
return msg.wParam;
}