PB install directory in register base

Everything else that doesn't fall into one of the other PB categories.
Denis
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

PB install directory in register base

Post by Denis »

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
A+
Denis
Fred
Administrator
Administrator
Posts: 18390
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

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

Denis
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Post by Denis »

Thanks Fred,

Denis :D
A+
Denis
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Don't work, because the buffer is not defined and has no length, so the first line must

Code: Select all

 Buffer$=Space(10000):BufferSize=Len(Buffer$)-1
GPI
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2148
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

Thanks Fred & GPI! To give all newbies a working example: :wink:

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$
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply