diff options
author | Simon Howard | 2009-06-12 17:35:39 +0000 |
---|---|---|
committer | Simon Howard | 2009-06-12 17:35:39 +0000 |
commit | 9fc871cdc51ddc335db803abae91eda42efdb2ed (patch) | |
tree | 5bd4ee9efd6320fdfa2f49cabf532a7bb2b061ae /wince | |
parent | c80600ef2c0ded9c51ebd0f169972149956d939b (diff) | |
download | chocolate-doom-9fc871cdc51ddc335db803abae91eda42efdb2ed.tar.gz chocolate-doom-9fc871cdc51ddc335db803abae91eda42efdb2ed.tar.bz2 chocolate-doom-9fc871cdc51ddc335db803abae91eda42efdb2ed.zip |
Set the USER environment variable based on the owner information from
the registry.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1598
Diffstat (limited to 'wince')
-rw-r--r-- | wince/env.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/wince/env.c b/wince/env.c index 72af2212..b3400627 100644 --- a/wince/env.c +++ b/wince/env.c @@ -40,17 +40,48 @@ static void SetEnvironment(char *env_string, wchar_t *wvalue) putenv(value); } +static int ReadOwnerName(wchar_t *value, DWORD len) +{ + HKEY key; + DWORD valtype; + + if (RegOpenKeyExW(HKEY_CURRENT_USER, + L"\\ControlPanel\\Owner", 0, + KEY_READ, &key) != ERROR_SUCCESS) + { + MessageBoxW(NULL, L"Can't open owner", L"Error", MB_OK); + return 0; + } + + valtype = REG_SZ; + + if (RegQueryValueExW(key, L"Name", NULL, &valtype, + (LPBYTE) value, &len) != ERROR_SUCCESS) + { + MessageBoxW(NULL, L"Can't read owner", L"Error", MB_OK); + return 0; + } + + MessageBoxW(NULL, value, L"Error", MB_OK); + + // Close the key + + RegCloseKey(key); + + return 1; +} + void PopulateEnvironment(void) { wchar_t temp[MAX_PATH]; - DWORD buf_len; // Username: - buf_len = UNLEN; - GetUserNameExW(NameDisplay, temp, &buf_len); - SetEnvironment("USER=", temp); - SetEnvironment("USERNAME=", temp); + if (ReadOwnerName(temp, MAX_PATH)) + { + SetEnvironment("USER=", temp); + SetEnvironment("USERNAME=", temp); + } // Temp dir: |