CodeExplorer uses this code to get the PB directory :
Code:
Procedure.s GetPBFolder() ; Retrieves Purebasic folder [empty string if not installed]
Protected hKey1.l, Type.l, Res.l, Folder$, lpbData.l, cbData.l, WindowsVersion.l
cbData = (#MAX_PATH * 2) + 2
lpbData = AllocateMemory(cbData)
Folder$=""
hKey1=0
Type=0
Res=-1
WindowsVersion = OSVersion()
If WindowsVersion = #PB_OS_Windows_95 Or WindowsVersion = #PB_OS_Windows_98 Or WindowsVersion = #PB_OS_Windows_ME
Debug "Detected OS : Windows 95/98/ME"
Res=RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Classes\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS, @hKey1)
ElseIf WindowsVersion = #PB_OS_Windows_NT3_51 Or WindowsVersion = #PB_OS_Windows_NT_4 Or WindowsVersion = #PB_OS_Windows_2000 Or WindowsVersion = #PB_OS_Windows_XP Or WindowsVersion = #PB_OS_Windows_Server_2003
Debug "Detected OS : Windows NT/2000/XP"
Res=RegOpenKeyEx_(#HKEY_CLASSES_ROOT, "Applications\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS, @hKey1)
Else
Debug "Detected OS : Windows Vista/Server 2008"
Res=RegOpenKeyEx_(#HKEY_CURRENT_USER, "Software\Classes\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS , @hKey1)
EndIf
If Res = #ERROR_SUCCESS And hKey1
If RegQueryValueEx_(hKey1, "", 0, @Type, lpbData, @cbData)=#ERROR_SUCCESS
Folder$ = PeekS(lpbData)
Folder$ = GetPathPart(StringField(Folder$,2,Chr(34)))
EndIf
RegCloseKey_(hKey1)
EndIf
If lpbData
FreeMemory(lpbData)
lpbData=0
EndIf
ProcedureReturn Folder$
EndProcedure
Does it work for you ?
The PB registry keys are changing with every version lately ...
<EDIT>
Update : updated PB folder detection code