Clarify GetUserName failure on Win9x
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7132 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
52cd125973
commit
932ad7d85b
2 changed files with 11 additions and 7 deletions
|
@ -23,7 +23,10 @@ void __declspec(dllexport) GetName(HWND hwndParent, int string_size,
|
|||
stack_t *th;
|
||||
if (!g_stacktop) return;
|
||||
th = (stack_t*) GlobalAlloc(GPTR, sizeof(stack_t) + g_stringsize*sizeof(TCHAR));
|
||||
GetUserName(th->text, &dwStringSize);
|
||||
if (!GetUserName(th->text, &dwStringSize)) // Fails with ERROR_NOT_LOGGED_ON on Win9x if you cancel the logon dialog.
|
||||
{
|
||||
*th->text = _T('\0');
|
||||
}
|
||||
th->next = *g_stacktop;
|
||||
*g_stacktop = th;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
Name "UserInfo.dll test"
|
||||
OutFile UserInfo.exe
|
||||
RequestExecutionLevel Highest
|
||||
|
||||
!define REALMSG "$\nOriginal non-restricted account type: $2"
|
||||
|
||||
Section
|
||||
ClearErrors
|
||||
UserInfo::GetName
|
||||
IfErrors Win9x
|
||||
IfErrors PluginFail
|
||||
Pop $0
|
||||
StrCmp $0 "" 0 +2 ; GetName can return a empty string on Win9x
|
||||
StrCpy $0 "?"
|
||||
UserInfo::GetAccountType
|
||||
Pop $1
|
||||
# GetOriginalAccountType will check the tokens of the original user of the
|
||||
|
@ -19,7 +22,7 @@ Section
|
|||
# "admin" while GetAccountType will return "user".
|
||||
UserInfo::GetOriginalAccountType
|
||||
Pop $2
|
||||
StrCmp $1 "Admin" 0 +3
|
||||
StrCmp $1 "Admin" 0 +3 ; Note: Win9x always returns "Admin"
|
||||
MessageBox MB_OK 'User "$0" is in the Administrators group${REALMSG}'
|
||||
Goto done
|
||||
StrCmp $1 "Power" 0 +3
|
||||
|
@ -34,10 +37,8 @@ Section
|
|||
MessageBox MB_OK "Unknown error"
|
||||
Goto done
|
||||
|
||||
Win9x:
|
||||
# This one means you don't need to care about admin or
|
||||
# not admin because Windows 9x doesn't either
|
||||
MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
|
||||
PluginFail:
|
||||
MessageBox MB_OK "Error! Unable to call plug-in!"
|
||||
|
||||
done:
|
||||
SectionEnd
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue