How I can get the path of the program folder?

There is an Env variable for this path?

P.S.
I have WinXP
Thanks.
Code: Select all
If Filesize("C:\Program Files") = -2
path$="C:\Program Files"
ElseIf Filesize("D:\Program Files") = -2
path$="D:\Program Files"
ElseIf Filesize("E:\Program Files") = -2
path$="E:\Program Files"
;etc.
Endif
Non-english users (PB has many of them) will thank you for sure!Randy Walker wrote: I'm lazy and I don't like fiddling with registry stuff (even to just read) so I would take the easy way out and use an if then approach.
Code: Select all
ProgramFiles$ = Space(#MAX_PATH)
GetEnvironmentVariable_("PROGRAMFILES", ProgramFiles$, #MAX_PATH)
Debug ProgramFiles$
Hold on one ding dang minute. Where in world did you ever get the notion that I was a programmer. A novice hacker at best maybe and I don't mean that in the typical misnomer (cracker) fashion. I understand a little bit and hack at it like hell until I get it to do something close to what I hope for. I consider programmers to be deeply versed individuals in the science and although I consider myself well versed in some respects, I have never ever refered to myself as a programmer.El_Choni wrote: @Randy: so you're one of these programmers...
Congratulation. With this code, you faild to find my Program files-folder. Because i have a german system and this folder is called "C:\Programme". And when you have installed more than on Windows in diffrent partitions...Randy Walker wrote:Every windows since '95 has used C:\Program Files as the default location for this directory..Code: Select all
If Filesize("C:\Program Files") = -2 path$="C:\Program Files" ElseIf Filesize("D:\Program Files") = -2 path$="D:\Program Files" ElseIf Filesize("E:\Program Files") = -2 path$="E:\Program Files" ;etc. Endif
Code: Select all
Procedure.s Reg_GetValue(topKey, sKeyName.s, sValueName.s, ComputerName.s)
lpData.s
GetValue.s =""
If Left(sKeyName, 1) = ""
sKeyName = Right(sKeyName, Len(sKeyName) - 1)
EndIf
If ComputerName = ""
GetHandle = RegOpenKeyEx_(topKey, sKeyName, 0, #KEY_ALL_ACCESS, @hKey)
Else
lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_ALL_ACCESS, @hKey)
EndIf
If GetHandle = #ERROR_SUCCESS
lpcbData = 255
lpData = Space(255)
GetHandle = RegQueryValueEx_(hKey, sValueName, 0, @lType, @lpData, @lpcbData)
If GetHandle = #ERROR_SUCCESS
Select lType
Case #REG_SZ
GetHandle = RegQueryValueEx_(hKey, sValueName, 0, @lType, @lpData, @lpcbData)
If GetHandle = 0
GetValue = Left(lpData, lpcbData - 1)
Else
GetValue = ""
EndIf
Case #REG_DWORD
GetHandle = RegQueryValueEx_(hKey, sValueName, 0, @lpType, @lpDataDWORD, @lpcbData)
If GetHandle = 0
GetValue = Str(lpDataDWORD)
Else
GetValue = "0"
EndIf
EndSelect
EndIf
EndIf
RegCloseKey_(hKey)
ProcedureReturn GetValue
EndProcedure
Procedure.s GetProgramFilesFolder()
Type = $2
location$=Reg_GetValue(#HKEY_LOCAL_MACHINE ,"SOFTWARE\Microsoft\Windows\CurrentVersion","ProgramFilesDir","")
ProcedureReturn location$
EndProcedure
Debug GetProgramFilesFolder()
GPI wrote:Congratulation. With this code, you faild to find my Program files-folder. Because i have a german system and this folder is called "C:\Programme". And when you have installed more than on Windows in diffrent partitions...
Very Bad code.
English is a foreign language for most people in the worldRandy Walker wrote:Who'd of thought anyone would install Windows in some foreign language?