Get Steam account name and install path: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Created by user: Afrow UK (talk, contrib).)
 
m (Adding new author and category links.)
Line 1: Line 1:
{|align=right
{{PageAuthor|Afrow UK}}
|<small>Author: [[{{ns:2}}:Afrow UK|Afrow UK]] ([[{{ns:3}}:Afrow UK|talk]], [[{{ns:-1}}:Contributions/Afrow UK|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==


Line 85: Line 83:
-Stu
-Stu


[[{{ns:14}}:Other Products Handling Functions]]
[[Category:Other Products Handling Functions]]

Revision as of 12:20, 24 June 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

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