mirror of
https://github.com/reactos/wine.git
synced 2025-02-11 07:05:30 +00:00
explorer: Convert the command line parsing to Unicode.
This commit is contained in:
parent
bbd32aacff
commit
9bbbebc2ce
@ -3,7 +3,7 @@ TOPOBJDIR = ../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = explorer.exe
|
||||
APPMODE = -mwindows
|
||||
APPMODE = -mwindows -municode
|
||||
IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll
|
||||
DELAYIMPORTS = comctl32
|
||||
|
||||
|
@ -74,21 +74,22 @@ static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPAR
|
||||
}
|
||||
|
||||
/* create the desktop and the associated X11 window, and make it the current desktop */
|
||||
static unsigned long create_desktop( const char *name, unsigned int width, unsigned int height )
|
||||
static unsigned long create_desktop( const WCHAR *name, unsigned int width, unsigned int height )
|
||||
{
|
||||
static const WCHAR rootW[] = {'r','o','o','t',0};
|
||||
HMODULE x11drv = GetModuleHandleA( "winex11.drv" );
|
||||
HDESK desktop;
|
||||
unsigned long xwin = 0;
|
||||
unsigned long (*create_desktop_func)(unsigned int, unsigned int);
|
||||
|
||||
desktop = CreateDesktopA( name, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
|
||||
desktop = CreateDesktopW( name, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
|
||||
if (!desktop)
|
||||
{
|
||||
WINE_ERR( "failed to create desktop %s error %d\n", wine_dbgstr_a(name), GetLastError() );
|
||||
WINE_ERR( "failed to create desktop %s error %d\n", wine_dbgstr_w(name), GetLastError() );
|
||||
ExitProcess( 1 );
|
||||
}
|
||||
/* magic: desktop "root" means use the X11 root window */
|
||||
if (x11drv && strcasecmp( name, "root" ))
|
||||
if (x11drv && strcmpiW( name, rootW ))
|
||||
{
|
||||
create_desktop_func = (void *)GetProcAddress( x11drv, "wine_create_desktop" );
|
||||
if (create_desktop_func) xwin = create_desktop_func( width, height );
|
||||
@ -97,19 +98,35 @@ static unsigned long create_desktop( const char *name, unsigned int width, unsig
|
||||
return xwin;
|
||||
}
|
||||
|
||||
/* parse the desktop size specification */
|
||||
static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *height )
|
||||
{
|
||||
WCHAR *end;
|
||||
|
||||
*width = strtoulW( size, &end, 10 );
|
||||
if (end == size) return FALSE;
|
||||
if (*end != 'x') return FALSE;
|
||||
size = end + 1;
|
||||
*height = strtoulW( size, &end, 10 );
|
||||
return !*end;
|
||||
}
|
||||
|
||||
/* retrieve the default desktop size from the X11 driver config */
|
||||
/* FIXME: this is for backwards compatibility, should probably be changed */
|
||||
static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height )
|
||||
{
|
||||
static const WCHAR keyW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
|
||||
'X','1','1',' ','D','r','i','v','e','r',0};
|
||||
static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
|
||||
HKEY hkey;
|
||||
char buffer[64];
|
||||
WCHAR buffer[64];
|
||||
DWORD size = sizeof(buffer);
|
||||
BOOL ret = FALSE;
|
||||
|
||||
/* @@ Wine registry key: HKCU\Software\Wine\X11 Driver */
|
||||
if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\X11 Driver", &hkey )) return FALSE;
|
||||
if (!RegQueryValueExA( hkey, "Desktop", 0, NULL, (LPBYTE)buffer, &size ))
|
||||
ret = (sscanf( buffer, "%ux%u", width, height ) == 2);
|
||||
if (RegOpenKeyW( HKEY_CURRENT_USER, keyW, &hkey )) return FALSE;
|
||||
if (!RegQueryValueExW( hkey, desktopW, 0, NULL, (LPBYTE)buffer, &size ))
|
||||
ret = parse_size( buffer, width, height );
|
||||
RegCloseKey( hkey );
|
||||
return ret;
|
||||
}
|
||||
@ -144,13 +161,12 @@ static void initialize_display_settings( HWND desktop )
|
||||
}
|
||||
}
|
||||
|
||||
static void set_desktop_window_title( HWND hwnd, const char *name )
|
||||
static void set_desktop_window_title( HWND hwnd, const WCHAR *name )
|
||||
{
|
||||
static const WCHAR desktop_nameW[] = {'W','i','n','e',' ','d','e','s','k','t','o','p',0};
|
||||
static const WCHAR desktop_name_separatorW[] = {' ', '-', ' ', 0};
|
||||
WCHAR *window_titleW = NULL;
|
||||
int window_title_len;
|
||||
int name_len;
|
||||
|
||||
if (!name[0])
|
||||
{
|
||||
@ -158,8 +174,7 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
|
||||
return;
|
||||
}
|
||||
|
||||
name_len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
|
||||
window_title_len = name_len * sizeof(WCHAR)
|
||||
window_title_len = strlenW(name) * sizeof(WCHAR)
|
||||
+ sizeof(desktop_name_separatorW)
|
||||
+ sizeof(desktop_nameW);
|
||||
window_titleW = HeapAlloc( GetProcessHeap(), 0, window_title_len );
|
||||
@ -169,8 +184,7 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
|
||||
return;
|
||||
}
|
||||
|
||||
MultiByteToWideChar( CP_ACP, 0, name, -1,
|
||||
window_titleW, name_len );
|
||||
strcpyW( window_titleW, name );
|
||||
strcatW( window_titleW, desktop_name_separatorW );
|
||||
strcatW( window_titleW, desktop_nameW );
|
||||
|
||||
@ -179,15 +193,16 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
|
||||
}
|
||||
|
||||
/* main desktop management function */
|
||||
void manage_desktop( char *arg )
|
||||
void manage_desktop( WCHAR *arg )
|
||||
{
|
||||
static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',0};
|
||||
MSG msg;
|
||||
HWND hwnd;
|
||||
unsigned long xwin = 0;
|
||||
unsigned int width, height;
|
||||
char *cmdline = NULL;
|
||||
char *p = arg;
|
||||
const char *name = NULL;
|
||||
WCHAR *cmdline = NULL;
|
||||
WCHAR *p = arg;
|
||||
const WCHAR *name = NULL;
|
||||
|
||||
/* get the rest of the command line (if any) */
|
||||
while (*p && !isspace(*p)) p++;
|
||||
@ -203,8 +218,8 @@ void manage_desktop( char *arg )
|
||||
if (*arg == '=' || *arg == ',')
|
||||
{
|
||||
arg++;
|
||||
if ((p = strchr( arg, ',' ))) *p++ = 0;
|
||||
if (!p || sscanf( p, "%ux%u", &width, &height ) != 2)
|
||||
if ((p = strchrW( arg, ',' ))) *p++ = 0;
|
||||
if (!p || !parse_size( p, &width, &height ))
|
||||
{
|
||||
width = 800;
|
||||
height = 600;
|
||||
@ -214,7 +229,7 @@ void manage_desktop( char *arg )
|
||||
}
|
||||
else if (get_default_desktop_size( &width, &height ))
|
||||
{
|
||||
name = "Default";
|
||||
name = defaultW;
|
||||
xwin = create_desktop( name, width, height );
|
||||
}
|
||||
|
||||
@ -245,13 +260,13 @@ void manage_desktop( char *arg )
|
||||
/* if we have a command line, execute it */
|
||||
if (cmdline)
|
||||
{
|
||||
STARTUPINFOA si;
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
memset( &si, 0, sizeof(si) );
|
||||
si.cb = sizeof(si);
|
||||
WINE_TRACE( "starting %s\n", wine_dbgstr_a(cmdline) );
|
||||
if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
||||
WINE_TRACE( "starting %s\n", wine_dbgstr_w(cmdline) );
|
||||
if (CreateProcessW( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
||||
{
|
||||
CloseHandle( pi.hThread );
|
||||
CloseHandle( pi.hProcess );
|
||||
|
@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "wine/unicode.h"
|
||||
#include "explorer_private.h"
|
||||
|
||||
typedef struct parametersTAG {
|
||||
@ -31,37 +31,25 @@ typedef struct parametersTAG {
|
||||
} parameters_struct;
|
||||
|
||||
|
||||
static int CopyPathString(LPWSTR target, LPSTR source)
|
||||
static int CopyPathString(LPWSTR target, LPWSTR source)
|
||||
{
|
||||
CHAR temp_buf[MAX_PATH];
|
||||
INT i = 0;
|
||||
|
||||
while (isspace(*source)) source++;
|
||||
while (isspaceW(*source)) source++;
|
||||
|
||||
if (*source == '\"')
|
||||
{
|
||||
source ++;
|
||||
while (*source != '\"')
|
||||
{
|
||||
temp_buf[i] = *source;
|
||||
i++;
|
||||
source++;
|
||||
}
|
||||
temp_buf[i] = 0;
|
||||
while (*source != '\"') target[i++] = *source++;
|
||||
target[i] = 0;
|
||||
source ++;
|
||||
i+=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (*source && !isspace(*source))
|
||||
{
|
||||
temp_buf[i] = *source;
|
||||
i++;
|
||||
source++;
|
||||
}
|
||||
temp_buf[i] = 0;
|
||||
while (*source && !isspaceW(*source)) target[i++] = *source++;
|
||||
target[i] = 0;
|
||||
}
|
||||
MultiByteToWideChar(CP_ACP,0,temp_buf,-1,target,MAX_PATH);
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -98,45 +86,52 @@ static void CopyPathRoot(LPWSTR root, LPWSTR path)
|
||||
* [/root,object] Specifies the root level of the view
|
||||
* [/select,object] parent folder is opened and specified object is selected
|
||||
*/
|
||||
static void ParseCommandLine(LPSTR commandline,parameters_struct *parameters)
|
||||
static void ParseCommandLine(LPWSTR commandline,parameters_struct *parameters)
|
||||
{
|
||||
LPSTR p;
|
||||
LPSTR p2;
|
||||
|
||||
static const WCHAR arg_n[] = {'/','n'};
|
||||
static const WCHAR arg_e[] = {'/','e',','};
|
||||
static const WCHAR arg_root[] = {'/','r','o','o','t',','};
|
||||
static const WCHAR arg_select[] = {'/','s','e','l','e','c','t',','};
|
||||
static const WCHAR arg_desktop[] = {'/','d','e','s','k','t','o','p'};
|
||||
|
||||
LPWSTR p, p2;
|
||||
|
||||
p2 = commandline;
|
||||
p = strchr(commandline,'/');
|
||||
p = strchrW(commandline,'/');
|
||||
while(p)
|
||||
{
|
||||
p++;
|
||||
if (strncmp(p,"n",1)==0)
|
||||
if (strncmpW(p, arg_n, sizeof(arg_n)/sizeof(WCHAR))==0)
|
||||
{
|
||||
parameters->explorer_mode = FALSE;
|
||||
p++;
|
||||
p += sizeof(arg_n)/sizeof(WCHAR);
|
||||
}
|
||||
else if (strncmp(p,"e,",2)==0)
|
||||
else if (strncmpW(p, arg_e, sizeof(arg_e)/sizeof(WCHAR))==0)
|
||||
{
|
||||
parameters->explorer_mode = TRUE;
|
||||
p+=2;
|
||||
p += sizeof(arg_e)/sizeof(WCHAR);
|
||||
}
|
||||
else if (strncmp(p,"root,",5)==0)
|
||||
else if (strncmpW(p, arg_root, sizeof(arg_root)/sizeof(WCHAR))==0)
|
||||
{
|
||||
p+=5;
|
||||
p += sizeof(arg_root)/sizeof(WCHAR);
|
||||
p+=CopyPathString(parameters->root,p);
|
||||
}
|
||||
else if (strncmp(p,"select,",7)==0)
|
||||
else if (strncmpW(p, arg_select, sizeof(arg_select)/sizeof(WCHAR))==0)
|
||||
{
|
||||
p+=7;
|
||||
p += sizeof(arg_select)/sizeof(WCHAR);
|
||||
p+=CopyPathString(parameters->selection,p);
|
||||
if (!parameters->root[0])
|
||||
CopyPathRoot(parameters->root,
|
||||
parameters->selection);
|
||||
}
|
||||
else if (strncmp(p,"desktop",7)==0)
|
||||
else if (strncmpW(p, arg_desktop, sizeof(arg_desktop)/sizeof(WCHAR))==0)
|
||||
{
|
||||
manage_desktop( p + 7 ); /* the rest of the command line is handled by desktop mode */
|
||||
p += sizeof(arg_desktop)/sizeof(WCHAR);
|
||||
manage_desktop( p ); /* the rest of the command line is handled by desktop mode */
|
||||
}
|
||||
else p++;
|
||||
|
||||
p2 = p;
|
||||
p = strchr(p,'/');
|
||||
p = strchrW(p,'/');
|
||||
}
|
||||
if (p2 && *p2)
|
||||
{
|
||||
@ -145,10 +140,10 @@ static void ParseCommandLine(LPSTR commandline,parameters_struct *parameters)
|
||||
}
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hinstance,
|
||||
HINSTANCE previnstance,
|
||||
LPSTR cmdline,
|
||||
int cmdshow)
|
||||
int WINAPI wWinMain(HINSTANCE hinstance,
|
||||
HINSTANCE previnstance,
|
||||
LPWSTR cmdline,
|
||||
int cmdshow)
|
||||
{
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION info;
|
||||
|
@ -21,13 +21,7 @@
|
||||
#ifndef __WINE_EXPLORER_PRIVATE_H
|
||||
#define __WINE_EXPLORER_PRIVATE_H
|
||||
|
||||
extern BOOL add_dos_device( const char *udi, const char *device,
|
||||
const char *mount_point, const char *type );
|
||||
extern BOOL remove_dos_device( const char *udi );
|
||||
|
||||
extern void manage_desktop( char *arg );
|
||||
extern void initialize_diskarbitration(void);
|
||||
extern void initialize_hal(void);
|
||||
extern void manage_desktop( WCHAR *arg );
|
||||
extern void initialize_systray(void);
|
||||
|
||||
#endif /* __WINE_EXPLORER_PRIVATE_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user