forked from Mirrors/wine-wine
explorer: Convert the command line parsing to Unicode.
parent
bbd32aacff
commit
9bbbebc2ce
|
@ -3,7 +3,7 @@ TOPOBJDIR = ../..
|
||||||
SRCDIR = @srcdir@
|
SRCDIR = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
MODULE = explorer.exe
|
MODULE = explorer.exe
|
||||||
APPMODE = -mwindows
|
APPMODE = -mwindows -municode
|
||||||
IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll
|
IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll
|
||||||
DELAYIMPORTS = comctl32
|
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 */
|
/* 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" );
|
HMODULE x11drv = GetModuleHandleA( "winex11.drv" );
|
||||||
HDESK desktop;
|
HDESK desktop;
|
||||||
unsigned long xwin = 0;
|
unsigned long xwin = 0;
|
||||||
unsigned long (*create_desktop_func)(unsigned int, unsigned int);
|
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)
|
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 );
|
ExitProcess( 1 );
|
||||||
}
|
}
|
||||||
/* magic: desktop "root" means use the X11 root window */
|
/* 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" );
|
create_desktop_func = (void *)GetProcAddress( x11drv, "wine_create_desktop" );
|
||||||
if (create_desktop_func) xwin = create_desktop_func( width, height );
|
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;
|
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 */
|
/* retrieve the default desktop size from the X11 driver config */
|
||||||
/* FIXME: this is for backwards compatibility, should probably be changed */
|
/* FIXME: this is for backwards compatibility, should probably be changed */
|
||||||
static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height )
|
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;
|
HKEY hkey;
|
||||||
char buffer[64];
|
WCHAR buffer[64];
|
||||||
DWORD size = sizeof(buffer);
|
DWORD size = sizeof(buffer);
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
/* @@ Wine registry key: HKCU\Software\Wine\X11 Driver */
|
/* @@ Wine registry key: HKCU\Software\Wine\X11 Driver */
|
||||||
if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\X11 Driver", &hkey )) return FALSE;
|
if (RegOpenKeyW( HKEY_CURRENT_USER, keyW, &hkey )) return FALSE;
|
||||||
if (!RegQueryValueExA( hkey, "Desktop", 0, NULL, (LPBYTE)buffer, &size ))
|
if (!RegQueryValueExW( hkey, desktopW, 0, NULL, (LPBYTE)buffer, &size ))
|
||||||
ret = (sscanf( buffer, "%ux%u", width, height ) == 2);
|
ret = parse_size( buffer, width, height );
|
||||||
RegCloseKey( hkey );
|
RegCloseKey( hkey );
|
||||||
return ret;
|
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_nameW[] = {'W','i','n','e',' ','d','e','s','k','t','o','p',0};
|
||||||
static const WCHAR desktop_name_separatorW[] = {' ', '-', ' ', 0};
|
static const WCHAR desktop_name_separatorW[] = {' ', '-', ' ', 0};
|
||||||
WCHAR *window_titleW = NULL;
|
WCHAR *window_titleW = NULL;
|
||||||
int window_title_len;
|
int window_title_len;
|
||||||
int name_len;
|
|
||||||
|
|
||||||
if (!name[0])
|
if (!name[0])
|
||||||
{
|
{
|
||||||
|
@ -158,8 +174,7 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
name_len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
|
window_title_len = strlenW(name) * sizeof(WCHAR)
|
||||||
window_title_len = name_len * sizeof(WCHAR)
|
|
||||||
+ sizeof(desktop_name_separatorW)
|
+ sizeof(desktop_name_separatorW)
|
||||||
+ sizeof(desktop_nameW);
|
+ sizeof(desktop_nameW);
|
||||||
window_titleW = HeapAlloc( GetProcessHeap(), 0, window_title_len );
|
window_titleW = HeapAlloc( GetProcessHeap(), 0, window_title_len );
|
||||||
|
@ -169,8 +184,7 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiByteToWideChar( CP_ACP, 0, name, -1,
|
strcpyW( window_titleW, name );
|
||||||
window_titleW, name_len );
|
|
||||||
strcatW( window_titleW, desktop_name_separatorW );
|
strcatW( window_titleW, desktop_name_separatorW );
|
||||||
strcatW( window_titleW, desktop_nameW );
|
strcatW( window_titleW, desktop_nameW );
|
||||||
|
|
||||||
|
@ -179,15 +193,16 @@ static void set_desktop_window_title( HWND hwnd, const char *name )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* main desktop management function */
|
/* 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;
|
MSG msg;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
unsigned long xwin = 0;
|
unsigned long xwin = 0;
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
char *cmdline = NULL;
|
WCHAR *cmdline = NULL;
|
||||||
char *p = arg;
|
WCHAR *p = arg;
|
||||||
const char *name = NULL;
|
const WCHAR *name = NULL;
|
||||||
|
|
||||||
/* get the rest of the command line (if any) */
|
/* get the rest of the command line (if any) */
|
||||||
while (*p && !isspace(*p)) p++;
|
while (*p && !isspace(*p)) p++;
|
||||||
|
@ -203,8 +218,8 @@ void manage_desktop( char *arg )
|
||||||
if (*arg == '=' || *arg == ',')
|
if (*arg == '=' || *arg == ',')
|
||||||
{
|
{
|
||||||
arg++;
|
arg++;
|
||||||
if ((p = strchr( arg, ',' ))) *p++ = 0;
|
if ((p = strchrW( arg, ',' ))) *p++ = 0;
|
||||||
if (!p || sscanf( p, "%ux%u", &width, &height ) != 2)
|
if (!p || !parse_size( p, &width, &height ))
|
||||||
{
|
{
|
||||||
width = 800;
|
width = 800;
|
||||||
height = 600;
|
height = 600;
|
||||||
|
@ -214,7 +229,7 @@ void manage_desktop( char *arg )
|
||||||
}
|
}
|
||||||
else if (get_default_desktop_size( &width, &height ))
|
else if (get_default_desktop_size( &width, &height ))
|
||||||
{
|
{
|
||||||
name = "Default";
|
name = defaultW;
|
||||||
xwin = create_desktop( name, width, height );
|
xwin = create_desktop( name, width, height );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,13 +260,13 @@ void manage_desktop( char *arg )
|
||||||
/* if we have a command line, execute it */
|
/* if we have a command line, execute it */
|
||||||
if (cmdline)
|
if (cmdline)
|
||||||
{
|
{
|
||||||
STARTUPINFOA si;
|
STARTUPINFOW si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
|
|
||||||
memset( &si, 0, sizeof(si) );
|
memset( &si, 0, sizeof(si) );
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
WINE_TRACE( "starting %s\n", wine_dbgstr_a(cmdline) );
|
WINE_TRACE( "starting %s\n", wine_dbgstr_w(cmdline) );
|
||||||
if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
if (CreateProcessW( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
||||||
{
|
{
|
||||||
CloseHandle( pi.hThread );
|
CloseHandle( pi.hThread );
|
||||||
CloseHandle( pi.hProcess );
|
CloseHandle( pi.hProcess );
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
|
#include "wine/unicode.h"
|
||||||
#include "explorer_private.h"
|
#include "explorer_private.h"
|
||||||
|
|
||||||
typedef struct parametersTAG {
|
typedef struct parametersTAG {
|
||||||
|
@ -31,37 +31,25 @@ typedef struct parametersTAG {
|
||||||
} parameters_struct;
|
} parameters_struct;
|
||||||
|
|
||||||
|
|
||||||
static int CopyPathString(LPWSTR target, LPSTR source)
|
static int CopyPathString(LPWSTR target, LPWSTR source)
|
||||||
{
|
{
|
||||||
CHAR temp_buf[MAX_PATH];
|
|
||||||
INT i = 0;
|
INT i = 0;
|
||||||
|
|
||||||
while (isspace(*source)) source++;
|
while (isspaceW(*source)) source++;
|
||||||
|
|
||||||
if (*source == '\"')
|
if (*source == '\"')
|
||||||
{
|
{
|
||||||
source ++;
|
source ++;
|
||||||
while (*source != '\"')
|
while (*source != '\"') target[i++] = *source++;
|
||||||
{
|
target[i] = 0;
|
||||||
temp_buf[i] = *source;
|
|
||||||
i++;
|
|
||||||
source++;
|
|
||||||
}
|
|
||||||
temp_buf[i] = 0;
|
|
||||||
source ++;
|
source ++;
|
||||||
i+=2;
|
i+=2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (*source && !isspace(*source))
|
while (*source && !isspaceW(*source)) target[i++] = *source++;
|
||||||
{
|
target[i] = 0;
|
||||||
temp_buf[i] = *source;
|
|
||||||
i++;
|
|
||||||
source++;
|
|
||||||
}
|
}
|
||||||
temp_buf[i] = 0;
|
|
||||||
}
|
|
||||||
MultiByteToWideChar(CP_ACP,0,temp_buf,-1,target,MAX_PATH);
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,45 +86,52 @@ static void CopyPathRoot(LPWSTR root, LPWSTR path)
|
||||||
* [/root,object] Specifies the root level of the view
|
* [/root,object] Specifies the root level of the view
|
||||||
* [/select,object] parent folder is opened and specified object is selected
|
* [/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;
|
static const WCHAR arg_n[] = {'/','n'};
|
||||||
LPSTR p2;
|
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;
|
p2 = commandline;
|
||||||
p = strchr(commandline,'/');
|
p = strchrW(commandline,'/');
|
||||||
while(p)
|
while(p)
|
||||||
{
|
{
|
||||||
p++;
|
if (strncmpW(p, arg_n, sizeof(arg_n)/sizeof(WCHAR))==0)
|
||||||
if (strncmp(p,"n",1)==0)
|
|
||||||
{
|
{
|
||||||
parameters->explorer_mode = FALSE;
|
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;
|
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);
|
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);
|
p+=CopyPathString(parameters->selection,p);
|
||||||
if (!parameters->root[0])
|
if (!parameters->root[0])
|
||||||
CopyPathRoot(parameters->root,
|
CopyPathRoot(parameters->root,
|
||||||
parameters->selection);
|
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;
|
p2 = p;
|
||||||
p = strchr(p,'/');
|
p = strchrW(p,'/');
|
||||||
}
|
}
|
||||||
if (p2 && *p2)
|
if (p2 && *p2)
|
||||||
{
|
{
|
||||||
|
@ -145,9 +140,9 @@ static void ParseCommandLine(LPSTR commandline,parameters_struct *parameters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hinstance,
|
int WINAPI wWinMain(HINSTANCE hinstance,
|
||||||
HINSTANCE previnstance,
|
HINSTANCE previnstance,
|
||||||
LPSTR cmdline,
|
LPWSTR cmdline,
|
||||||
int cmdshow)
|
int cmdshow)
|
||||||
{
|
{
|
||||||
STARTUPINFOW si;
|
STARTUPINFOW si;
|
||||||
|
|
|
@ -21,13 +21,7 @@
|
||||||
#ifndef __WINE_EXPLORER_PRIVATE_H
|
#ifndef __WINE_EXPLORER_PRIVATE_H
|
||||||
#define __WINE_EXPLORER_PRIVATE_H
|
#define __WINE_EXPLORER_PRIVATE_H
|
||||||
|
|
||||||
extern BOOL add_dos_device( const char *udi, const char *device,
|
extern void manage_desktop( WCHAR *arg );
|
||||||
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 initialize_systray(void);
|
extern void initialize_systray(void);
|
||||||
|
|
||||||
#endif /* __WINE_EXPLORER_PRIVATE_H */
|
#endif /* __WINE_EXPLORER_PRIVATE_H */
|
||||||
|
|
Loading…
Reference in New Issue