Declare.s AppPath()
Declare.s InstrRev(xChar1.s)

AppPathC.s = AppPath()
xLong1.l
xLong2.l
xLong3.l
xBool1.l

xChar1$ = "Software\Maxis\The Sims"
If RegOpenKeyEx_(-2147483646, @xChar1$, 0, 983103, @xLong3) = 0 
  xChar1$ = "HighResolution": xLong2 = 256: xChar2$ = Space(xLong2)
  If RegQueryValueEx_(xLong3, @xChar1$, 0, xLong4.l, @xChar2$, @xLong2) = 0
    If xChar2$ = "1"
      xBool1 = 1
      EndIf
    EndIf
  RegCloseKey_(xLong3)

  OnErrorResume()
  xType1.StartupInfo
  xType2.Process_Information
  xType1\cb = 68
  xChar1$ = AppPathC + "\Sims.dat"
  xType1\lpTitle = @xChar1$
  If xBool1
    CreateProcess_(0, Chr(34) + AppPathC + "\Sims.dat" + Chr(34) + " -r1024x768", 0, 0, 0, 0, 0, AppPathC, @xType1, @xType2)
    Else
    CreateProcess_(0, Chr(34) + AppPathC + "\Sims.dat" + Chr(34), 0, 0, 0, 0, 0, AppPathC, @xType1, @xType2)
    EndIf
  OnErrorGoto(0)
  Else
  MessageRequester("Error", "Cannot access windows regestry; Please run setup first!")
  EndIf

End






Procedure.s AppPath()
  xLong1.l
  Result.s

  xLong1 = GetCommandLine_()
  If xLong1 <> 0
    Result = PeekS(xLong1, 65535)
    If Left(Result, 1) = Chr(34) 
      xLong1 = Len(Result) - 2
      If xLong1 = -1
        Result = Mid(Result, 2, xLong1 + 1)
        Else
        Result = Mid(Result, 2, xLong1)
        EndIf
      xLong1 = FindString(Result, Chr(34), 1)
      Else
      xLong1 = FindString(Result, " ", 1)
      EndIf
    If xLong1 <> 0 
      Result = Left(Result, xLong1 - 1)
      EndIf

    Result = InstrRev(Result)
;    Result = "e:\TheSims"
    ProcedureReturn = Result
    EndIf
  EndProcedure

Procedure.s InstrRev(xChar1.s)
  xLong1.l
  xLong2.l

  While 1
    xLong1 = FindString(xChar1, "\", xLong2 + 1)
    If xLong1 = 0 
      Break
      Else
      xLong2 = xLong1
      EndIf
    Wend
  If xLong2 > 0
    ProcedureReturn = Left(xChar1, xLong2 - 1)
    EndIf
  EndProcedure


; IDE Options = PureBasic v3.94 (Windows - x86)
; CursorPosition = 32
; FirstLine = 32
; Folding = -
; EnableXP
; EnableOnError
; UseIcon = simscd.ico
; Executable = Sims.exe
; DisableDebugger
; IncludeVersionInfo
; VersionField0 = 1,1,0,0
; VersionField1 = 1,1,0,0
; VersionField2 = ctuser
; VersionField3 = Sims Launcher
; VersionField4 = 1,1,0,0
; VersionField5 = 1,1,0,0
; VersionField6 = Sims Launcher
; VersionField7 = SimsLnch
; VersionField8 = SimsLnch
; VersionField9 = Copyright 2005 by Jan Vorel