Get Steam account name and install path: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Adding new author and category links.) |
(→Usage) |
||
Line 13: | Line 13: | ||
Pop $R1 ; steam path e.g. C:\Valve\Steam | Pop $R1 ; steam path e.g. C:\Valve\Steam | ||
</highlight-nsis> | </highlight-nsis> | ||
If $R0 and $R1 are emptyu "" then Steam is not installed. | |||
If no account name is found, $R0 is "[ACCOUNT_NAME]". | |||
== The Function == | == The Function == |
Revision as of 09:28, 2 October 2005
Author: Afrow UK (talk, contrib) |
Description
This gets the account name for Valve's Steam (Half-Life 1, 2 etc) It also returns Steam's install path (e.g. C:\Valve\Steam)
Usage
Call GetSteamAccountName Pop $R0 ; account name e.g. afrow uk Pop $R1 ; steam path e.g. C:\Valve\Steam
If $R0 and $R1 are emptyu "" then Steam is not installed. If no account name is found, $R0 is "[ACCOUNT_NAME]".
The Function
Function GetSteamAccountName Push $R0 Push $R1 Push $R2 Push $R3 ReadRegStr $R0 HKCU "Software\Valve\Steam" "SteamExe" StrCmp $R0 "" noSteam StrCpy $R1 0 IntOp $R1 $R1 - 1 StrCpy $R2 $R0 1 $R1 StrCmp $R2 "" noAccount StrCmp $R2 "/" 0 -3 StrCpy $R0 $R0 $R1 StrCpy $R1 0 IntOp $R1 $R1 + 1 StrCpy $R2 $R0 1 -$R1 StrCmp $R2 "" +8 StrCmp $R2 "/" 0 -3 StrCpy $R2 $R0 -$R1 IntOp $R1 $R1 - 1 StrCpy $R3 $R0 "" -$R1 StrCpy $R0 "$R2\$R3" IntOp $R1 $R1 + 1 Goto -9 FindFirst $R1 $R2 "$R0\steamapps\*.*" loopFile: StrCmp $R2 "SourceMods" nextFile StrCmp $R2 "." nextFile StrCmp $R2 ".." nextFile IfFileExists "$R0\steamapps\$R2\*.*" done nextFile: ClearErrors FindNext $R1 $R2 IfErrors 0 loopFile FindClose $R1 noAccount: StrCpy $R2 "[ACCOUNT_NAME]" done: StrCpy $R1 $R0 StrCpy $R0 $R2 Goto +3 noSteam: StrCpy $R1 "" StrCpy $R0 "" Pop $R3 Pop $R2 Exch $R1 Exch Exch $R0 FunctionEnd
Written for new NSIS user in this forum topic (modified afterwards for Source mod developers).
-Stu