Old 4th November 2006, 19:27   #1
{_trueparuex^}
Senior Member
 
{_trueparuex^}'s Avatar
 
Join Date: Dec 2005
Location: Glow
Posts: 285
Will %COMPUTERNAME% work on NT/9x?

I am using ReadEnvStr to read COMPUTERNAME and USERNAME environment variables and it works just fine on XP/Win2k, but does anyone know will it work on NT/9x?

I know there is other ways read the computername or username, but if ReadEnvStr method works on NT/9x I would rather use it than any other method.

The guy with the ridiculous username. Thou shall call him PaR instead.
Visit My Website
{_trueparuex^} is offline   Reply With Quote
Old 4th November 2006, 19:31   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
UserInfo::GetName can get you the user name using Windows API. To get the computer name, the System plug-in is required.
code:
System::Call "kernel32::GetComputerName(t .r0, *i ${NSIS_MAX_STRLEN})"
No need for environment variables or the registry

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 4th November 2006, 19:58   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
To elaborate a bit more, I don't trust the environment variables. I have never seen official documentation concerning which versions of Windows export which variables. And on top of that, the user can easily change them and leave you with false values. I put my trust in the API.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 5th November 2006, 10:03   #4
{_trueparuex^}
Senior Member
 
{_trueparuex^}'s Avatar
 
Join Date: Dec 2005
Location: Glow
Posts: 285
Thank you. That will do just fine. And with quick search to msdn.
code:
System::Call "Advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN})"

The guy with the ridiculous username. Thou shall call him PaR instead.
Visit My Website
{_trueparuex^} is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump