Commit ac8da35b authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

regsvr32: Use message boxes by default for output.

regsvr32 is in GUI subsystem and shouldn't interact with console. Keeping unix I/O output in silent mode. Removing -c option as not existing in native. Signed-off-by: 's avatarEric Pouech <epouech@codeweavers.com>
parent d9fcbf45
...@@ -4581,8 +4581,8 @@ static UINT ACTION_RemoveIniValues( MSIPACKAGE *package ) ...@@ -4581,8 +4581,8 @@ static UINT ACTION_RemoveIniValues( MSIPACKAGE *package )
static void register_dll( const WCHAR *dll, BOOL unregister ) static void register_dll( const WCHAR *dll, BOOL unregister )
{ {
static const WCHAR regW[] = L"regsvr32.exe \"%s\""; static const WCHAR regW[] = L"regsvr32.exe /s \"%s\"";
static const WCHAR unregW[] = L"regsvr32.exe /u \"%s\""; static const WCHAR unregW[] = L"regsvr32.exe /s /u \"%s\"";
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFOW si; STARTUPINFOW si;
WCHAR *cmd; WCHAR *cmd;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <winternl.h> #include <winternl.h>
#include <winnls.h>
#include <ole2.h> #include <ole2.h>
#include "regsvr32.h" #include "regsvr32.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -34,51 +35,50 @@ typedef HRESULT (WINAPI *DLLREGISTER) (void); ...@@ -34,51 +35,50 @@ typedef HRESULT (WINAPI *DLLREGISTER) (void);
typedef HRESULT (WINAPI *DLLUNREGISTER) (void); typedef HRESULT (WINAPI *DLLUNREGISTER) (void);
typedef HRESULT (WINAPI *DLLINSTALL) (BOOL,LPCWSTR); typedef HRESULT (WINAPI *DLLINSTALL) (BOOL,LPCWSTR);
static BOOL Silent = FALSE; static BOOL Silent;
static void WINAPIV output_write(UINT id, ...) static void WINAPIV output_write(BOOL with_usage, UINT id, ...)
{ {
WCHAR buffer[4096];
WCHAR fmt[1024]; WCHAR fmt[1024];
va_list va_args; va_list va_args;
WCHAR *str; DWORD len;
DWORD len, nOut; LCID current_lcid;
if (Silent) return; current_lcid = GetThreadLocale();
if (Silent) /* force en-US not to have localized strings */
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
if (!LoadStringW(GetModuleHandleW(NULL), id, fmt, ARRAY_SIZE(fmt))) if (!LoadStringW(GetModuleHandleW(NULL), id, fmt, ARRAY_SIZE(fmt)))
{ {
WINE_FIXME("LoadString failed with %ld\n", GetLastError()); WINE_FIXME("LoadString failed with %ld\n", GetLastError());
SetThreadLocale(current_lcid);
return; return;
} }
va_start(va_args, id); va_start(va_args, id);
len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER, len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING,
fmt, 0, 0, (LPWSTR)&str, 0, &va_args); fmt, 0, 0, buffer, ARRAY_SIZE(buffer), &va_args);
va_end(va_args); va_end(va_args);
if (len == 0 && GetLastError() != ERROR_NO_WORK_DONE) if (len == 0 && GetLastError() != ERROR_NO_WORK_DONE)
{ {
WINE_FIXME("Could not format string: le=%lu, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt)); WINE_FIXME("Could not format string: le=%lu, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt));
SetThreadLocale(current_lcid);
return; return;
} }
if (with_usage &&
/* WriteConsole fails if its output is redirected to a file. !LoadStringW(GetModuleHandleW(NULL), STRING_USAGE,
* If this occurs, we should use an OEM codepage and call WriteFile. &buffer[wcslen(buffer)], ARRAY_SIZE(buffer) - wcslen(buffer)))
*/
if (!WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &nOut, NULL))
{ {
DWORD lenA; WINE_FIXME("LoadString failed with %ld\n", GetLastError());
char *strA; SetThreadLocale(current_lcid);
return;
lenA = WideCharToMultiByte(GetOEMCP(), 0, str, len, NULL, 0, NULL, NULL);
strA = HeapAlloc(GetProcessHeap(), 0, lenA);
if (strA)
{
WideCharToMultiByte(GetOEMCP(), 0, str, len, strA, lenA, NULL, NULL);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), strA, lenA, &nOut, FALSE);
HeapFree(GetProcessHeap(), 0, strA);
}
} }
LocalFree(str); if (Silent)
MESSAGE("%ls", buffer);
else
MessageBoxW(NULL, buffer, L"RegSvr32", MB_OK);
SetThreadLocale(current_lcid);
} }
static LPCWSTR find_arg_start(LPCWSTR cmdline) static LPCWSTR find_arg_start(LPCWSTR cmdline)
...@@ -180,13 +180,13 @@ static VOID *LoadProc(const WCHAR* strDll, const char* procName, HMODULE* DllHan ...@@ -180,13 +180,13 @@ static VOID *LoadProc(const WCHAR* strDll, const char* procName, HMODULE* DllHan
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( (HMODULE)((ULONG_PTR)module & ~3) ); IMAGE_NT_HEADERS *nt = RtlImageNtHeader( (HMODULE)((ULONG_PTR)module & ~3) );
reexec_self( nt->FileHeader.Machine ); reexec_self( nt->FileHeader.Machine );
} }
output_write(STRING_DLL_LOAD_FAILED, strDll); output_write(FALSE, STRING_DLL_LOAD_FAILED, strDll);
ExitProcess(LOADLIBRARY_FAILED); ExitProcess(LOADLIBRARY_FAILED);
} }
proc = (VOID *) GetProcAddress(*DllHandle, procName); proc = (VOID *) GetProcAddress(*DllHandle, procName);
if(!proc) if(!proc)
{ {
output_write(STRING_PROC_NOT_IMPLEMENTED, procName, strDll); output_write(FALSE, STRING_PROC_NOT_IMPLEMENTED, procName, strDll);
FreeLibrary(*DllHandle); FreeLibrary(*DllHandle);
return NULL; return NULL;
} }
...@@ -206,10 +206,10 @@ static int RegisterDll(const WCHAR* strDll, BOOL firstDll) ...@@ -206,10 +206,10 @@ static int RegisterDll(const WCHAR* strDll, BOOL firstDll)
hr = pfRegister(); hr = pfRegister();
if(FAILED(hr)) if(FAILED(hr))
{ {
output_write(STRING_REGISTER_FAILED, strDll); output_write(FALSE, STRING_REGISTER_FAILED, strDll);
return DLLSERVER_FAILED; return DLLSERVER_FAILED;
} }
output_write(STRING_REGISTER_SUCCESSFUL, strDll); output_write(FALSE, STRING_REGISTER_SUCCESSFUL, strDll);
if(DllHandle) if(DllHandle)
FreeLibrary(DllHandle); FreeLibrary(DllHandle);
...@@ -229,10 +229,10 @@ static int UnregisterDll(const WCHAR* strDll, BOOL firstDll) ...@@ -229,10 +229,10 @@ static int UnregisterDll(const WCHAR* strDll, BOOL firstDll)
hr = pfUnregister(); hr = pfUnregister();
if(FAILED(hr)) if(FAILED(hr))
{ {
output_write(STRING_UNREGISTER_FAILED, strDll); output_write(FALSE, STRING_UNREGISTER_FAILED, strDll);
return DLLSERVER_FAILED; return DLLSERVER_FAILED;
} }
output_write(STRING_UNREGISTER_SUCCESSFUL, strDll); output_write(FALSE, STRING_UNREGISTER_SUCCESSFUL, strDll);
if(DllHandle) if(DllHandle)
FreeLibrary(DllHandle); FreeLibrary(DllHandle);
...@@ -253,15 +253,15 @@ static int InstallDll(BOOL install, const WCHAR *strDll, const WCHAR *command_li ...@@ -253,15 +253,15 @@ static int InstallDll(BOOL install, const WCHAR *strDll, const WCHAR *command_li
if(FAILED(hr)) if(FAILED(hr))
{ {
if (install) if (install)
output_write(STRING_INSTALL_FAILED, strDll); output_write(FALSE, STRING_INSTALL_FAILED, strDll);
else else
output_write(STRING_UNINSTALL_FAILED, strDll); output_write(FALSE, STRING_UNINSTALL_FAILED, strDll);
return DLLSERVER_FAILED; return DLLSERVER_FAILED;
} }
if (install) if (install)
output_write(STRING_INSTALL_SUCCESSFUL, strDll); output_write(FALSE, STRING_INSTALL_SUCCESSFUL, strDll);
else else
output_write(STRING_UNINSTALL_SUCCESSFUL, strDll); output_write(FALSE, STRING_UNINSTALL_SUCCESSFUL, strDll);
if(DllHandle) if(DllHandle)
FreeLibrary(DllHandle); FreeLibrary(DllHandle);
...@@ -340,12 +340,8 @@ int __cdecl wmain(int argc, WCHAR* argv[]) ...@@ -340,12 +340,8 @@ int __cdecl wmain(int argc, WCHAR* argv[])
case 'n': case 'n':
CallRegister = FALSE; CallRegister = FALSE;
break; break;
case 'c':
/* console output */;
break;
default: default:
output_write(STRING_UNRECOGNIZED_SWITCH, argv[i]); output_write(TRUE, STRING_UNRECOGNIZED_SWITCH, argv[i]);
output_write(STRING_USAGE);
return INVALID_ARG; return INVALID_ARG;
} }
argv[i] = NULL; argv[i] = NULL;
...@@ -401,8 +397,7 @@ int __cdecl wmain(int argc, WCHAR* argv[]) ...@@ -401,8 +397,7 @@ int __cdecl wmain(int argc, WCHAR* argv[])
if (!DllFound) if (!DllFound)
{ {
output_write(STRING_HEADER); output_write(TRUE, STRING_HEADER);
output_write(STRING_USAGE);
return INVALID_ARG; return INVALID_ARG;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment