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 <stdio.h>
#include <shellapi.h> #include <shellapi.h>
#include <objsel.h> #include <objsel.h>
#include <objbase.h>
#include "main.h" #include "main.h"
#include "regproc.h" #include "regproc.h"
@ -680,19 +681,25 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
HRESULT hRet; HRESULT hRet;
hRet = InitializeRemoteRegistryPicker(&ObjectPicker); hRet = CoInitialize(NULL);
if (SUCCEEDED(hRet)) if (SUCCEEDED(hRet))
{ {
hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker, hRet = InitializeRemoteRegistryPicker(&ObjectPicker);
hWnd, if (SUCCEEDED(hRet))
szComputerName,
sizeof(szComputerName) / sizeof(szComputerName[0]));
if (hRet == S_OK)
{ {
/* FIXME - connect to the registry */ hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
hWnd,
szComputerName,
sizeof(szComputerName) / sizeof(szComputerName[0]));
if (hRet == S_OK)
{
/* FIXME - connect to the registry */
}
FreeObjectPicker(ObjectPicker);
} }
FreeObjectPicker(ObjectPicker); CoUninitialize();
} }
return TRUE; return TRUE;

View file

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