Alexandre Julliard : kernel32: Load USERNAME and USERPROFILE from the volatile environment.
Alexandre Julliard
julliard at winehq.org
Thu Jan 28 11:15:37 CST 2010
Module: wine
Branch: master
Commit: 0daf0528daeea6c345d85cd98f853e70daa220d3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0daf0528daeea6c345d85cd98f853e70daa220d3
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jan 28 13:34:05 2010 +0100
kernel32: Load USERNAME and USERPROFILE from the volatile environment.
---
dlls/kernel32/process.c | 35 ++++++-----------------------------
1 files changed, 6 insertions(+), 29 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 0c60ce5..ae6aa31 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -524,28 +524,14 @@ static void set_additional_environment(void)
'P','r','o','f','i','l','e','L','i','s','t',0};
static const WCHAR profiles_valueW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
static const WCHAR all_users_valueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
- static const WCHAR usernameW[] = {'U','S','E','R','N','A','M','E',0};
- static const WCHAR userprofileW[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
static const WCHAR allusersW[] = {'A','L','L','U','S','E','R','S','P','R','O','F','I','L','E',0};
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
- WCHAR *user_name = NULL, *profile_dir = NULL, *all_users_dir = NULL;
+ WCHAR *profile_dir = NULL, *all_users_dir = NULL;
HANDLE hkey;
- const char *name = wine_get_user_name();
DWORD len;
- /* set the USERNAME variable */
-
- len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
- if (len)
- {
- user_name = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
- MultiByteToWideChar( CP_UNIXCP, 0, name, -1, user_name, len );
- SetEnvironmentVariableW( usernameW, user_name );
- }
- else WARN( "user name %s not convertible.\n", debugstr_a(name) );
-
- /* set the USERPROFILE and ALLUSERSPROFILE variables */
+ /* set the ALLUSERSPROFILE variables */
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
@@ -561,31 +547,22 @@ static void set_additional_environment(void)
NtClose( hkey );
}
- if (profile_dir)
+ if (profile_dir && all_users_dir)
{
WCHAR *value, *p;
- if (all_users_dir) len = max( len, strlenW(all_users_dir) + 1 );
- len += strlenW(profile_dir) + 1;
+ len = strlenW(profile_dir) + strlenW(all_users_dir) + 2;
value = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
strcpyW( value, profile_dir );
p = value + strlenW(value);
if (p > value && p[-1] != '\\') *p++ = '\\';
- if (user_name) {
- strcpyW( p, user_name );
- SetEnvironmentVariableW( userprofileW, value );
- }
- if (all_users_dir)
- {
- strcpyW( p, all_users_dir );
- SetEnvironmentVariableW( allusersW, value );
- }
+ strcpyW( p, all_users_dir );
+ SetEnvironmentVariableW( allusersW, value );
HeapFree( GetProcessHeap(), 0, value );
}
HeapFree( GetProcessHeap(), 0, all_users_dir );
HeapFree( GetProcessHeap(), 0, profile_dir );
- HeapFree( GetProcessHeap(), 0, user_name );
}
/***********************************************************************
More information about the wine-cvs
mailing list