diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 8ee838705f..7641b918e8 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -2775,13 +2775,6 @@ static BOOL Process_Link( LPCWSTR linkname, BOOL bWait ) return 1; } - r = CoInitialize( NULL ); - if( FAILED( r ) ) - { - WINE_ERR("CoInitialize failed\n"); - return 1; - } - r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID *) &sl ); if( FAILED( r ) ) @@ -2817,8 +2810,6 @@ static BOOL Process_Link( LPCWSTR linkname, BOOL bWait ) IPersistFile_Release( pf ); IShellLinkW_Release( sl ); - CoUninitialize(); - return !r; } @@ -2845,13 +2836,6 @@ static BOOL Process_URL( LPCWSTR urlname, BOOL bWait ) return 1; } - r = CoInitialize( NULL ); - if( FAILED( r ) ) - { - WINE_ERR("CoInitialize failed\n"); - return 1; - } - r = CoCreateInstance( &CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, &IID_IUniformResourceLocatorW, (LPVOID *) &url ); if( FAILED( r ) ) @@ -2882,8 +2866,6 @@ static BOOL Process_URL( LPCWSTR urlname, BOOL bWait ) IPersistFile_Release( pf ); url->lpVtbl->Release( url ); - CoUninitialize(); - return !r; } @@ -3116,11 +3098,19 @@ int PASCAL wWinMain (HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int sh LPWSTR token = NULL, p; BOOL bWait = FALSE; BOOL bURL = FALSE; + HRESULT hr; int ret = 0; if (!init_xdg()) return 1; + hr = CoInitialize(NULL); + if (FAILED(hr)) + { + WINE_ERR("could not initialize COM, error 0x%08X\n", hr); + return 1; + } + for( p = cmdline; p && *p; ) { token = next_token( &p ); @@ -3160,5 +3150,6 @@ int PASCAL wWinMain (HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int sh } } + CoUninitialize(); return ret; }