I'm looking for the install directory of PB in register base.
How to get it (in PB of course) ?
Can anybody send URLs for base register explanations sites ?
Thanks
Denis
PB install directory in register base
Code: Select all
If GetVersion_() & $ff0000 ; Windows NT/XP
If RegOpenKeyEx_(#HKEY_CLASSES_ROOT, "Applications\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS , @Key) = #ERROR_SUCCESS
If RegQueryValueEx_(Key, "", 0, @Type, @Buffer$, @BufferSize) = #ERROR_SUCCESS
OutputDirectory$ = GetPathPart(Mid(Buffer$, 2, Len(Buffer$)-7))
EndIf
EndIf
Else ; The same for Win9x
If RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Classes\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS , @Key) = #ERROR_SUCCESS
If RegQueryValueEx_(Key, "", 0, @Type, @Buffer$, @BufferSize) = #ERROR_SUCCESS
OutputDirectory$ = GetPathPart(Mid(Buffer$, 2, Len(Buffer$)-7))
EndIf
EndIf
EndIf
Don't work, because the buffer is not defined and has no length, so the first line must
GPI
Code: Select all
Buffer$=Space(10000):BufferSize=Len(Buffer$)-1- Andre
- PureBasic Team

- Posts: 2148
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Thanks Fred & GPI! To give all newbies a working example:
Code: Select all
Buffer$=Space(10000):BufferSize=Len(Buffer$)-1
If GetVersion_() & $ff0000 ; Windows NT/XP
If RegOpenKeyEx_(#HKEY_CLASSES_ROOT, "Applications\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS , @Key) = #ERROR_SUCCESS
If RegQueryValueEx_(Key, "", 0, @Type, @Buffer$, @BufferSize) = #ERROR_SUCCESS
OutputDirectory$ = GetPathPart(Mid(Buffer$, 2, Len(Buffer$)-7))
EndIf
EndIf
Else ; The same for Win9x
If RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Classes\PureBasic.exe\shell\open\command", 0, #KEY_ALL_ACCESS , @Key) = #ERROR_SUCCESS
If RegQueryValueEx_(Key, "", 0, @Type, @Buffer$, @BufferSize) = #ERROR_SUCCESS
OutputDirectory$ = GetPathPart(Mid(Buffer$, 2, Len(Buffer$)-7))
EndIf
EndIf
EndIf
Debug OutputDirectory$
