Hi all, can anyone show me some (MASM) code to tell if the current user is Admin or not? Or direct me to a website? I need to know if the user is Admin or has Admin rights so my program can display some values from the Registry that the Admins can only set. I was going to add this feature to my program when I wrote in VB but never gotten around to it, all I remember was that is has to do with tokens or SID or something.
Any help much appreciated!
Any help much appreciated!
Odd that I didn't find that post stryker cause I did a search of the board before my post. Hmmm
Thanks
Thanks
lol, that thread doesn't contain any key words of Is Admin or whatever but it does contain similar purpose to what your after.
Don't worry. :grin:
Don't worry. :grin:
I would simply call the IsUserAnAdmin API :grin:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/isuseranadmin.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/isuseranadmin.asp
IsUserAnAdmin.
Jeesh, how'd I miss this one? Anyway, this is for Win 2K and higher:
Minimum operating systems:
Windows 2000
So this function would work on 2000 and XP. How about something that would work on NT4 an maybe lower?
Ok ya crazy penguin, just tried it and DUH, it is not in my user32.lib/inc, how do I updated my lib files? I do have the platform sdk installed with the header and include files....
Jeesh, how'd I miss this one? Anyway, this is for Win 2K and higher:
Minimum operating systems:
Windows 2000
So this function would work on 2000 and XP. How about something that would work on NT4 an maybe lower?
Ok ya crazy penguin, just tried it and DUH, it is not in my user32.lib/inc, how do I updated my lib files? I do have the platform sdk installed with the header and include files....
So this function would work on 2000 and XP. How about something that would work on NT4 an maybe lower?
"Lower" than NT 4.0 are no security rights. Or do you mean NT 3.51? :)
Originally posted by Gunner
Ok ya crazy penguin, just tried it and DUH, it is not in my user32.lib/inc, how do I updated my lib files? I do have the platform sdk installed with the header and include files....
Ok ya crazy penguin, just tried it and DUH, it is not in my user32.lib/inc, how do I updated my lib files? I do have the platform sdk installed with the header and include files....
Well, download the PlatformSDK, copy the *.lib files to the MASM32 lib directory and run the "rebuild.bat" (\masm32\rebuild.bat) to rebuild the include files. That should work ;)
I wrote "download", because you really need the latest SDK. The "IsUserAnAdmin" function is part of the shortly released MS Middleware APIs, so I doubt it will be documented in earlier SDKs.
gunner,
shouldn't the link I just gave enough for win NT/2K/XP.
quoting from this link: http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q118626&
shouldn't the link I just gave enough for win NT/2K/XP.
quoting from this link: http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q118626&
HOWTO: Determine Whether a Thread Is Running in User Context of Local Administrator Account
The information in this article applies to:
Microsoft Win32 Application Programming Interface (API), when used with:
the operating system: Microsoft Windows NT
the operating system: Microsoft Windows 2000
the operating system: Microsoft Windows XP
Instead of updating the .lib files you can use LoadLibrary/GetProcAddress...The information in this article applies to:
Microsoft Win32 Application Programming Interface (API), when used with:
the operating system: Microsoft Windows NT
the operating system: Microsoft Windows 2000
the operating system: Microsoft Windows XP
Rob,
You can use the complete XP set of libraries if you have a late enough platformsdk but be aware that a couple of the libraries that have no APIs in them cause a problem with the L2INCA utility so the trick is to delete them out as you don't use them and keep going until the whole set build OK into the matching include files.
Its no big deal to do and it means you have a complete set for XP and lower.
Regards,
hutch@movsd.com
You can use the complete XP set of libraries if you have a late enough platformsdk but be aware that a couple of the libraries that have no APIs in them cause a problem with the L2INCA utility so the trick is to delete them out as you don't use them and keep going until the whole set build OK into the matching include files.
Its no big deal to do and it means you have a complete set for XP and lower.
Regards,
hutch@movsd.com
Thank you all! I have some things to play around with now. Never thought about LoadLibrary/GetProcAddress, still new to this great thing ya know ;-)