How to detect the programs folder

How to detect the programs folder

Postby Piscicelli Zingoni » Sat Feb 04, 2006 10:58 am

Hi, i forgot how to detect the standard folder programs, example C:\PROGRAMS (english) or
C:\PROGRAMMI (ITALIAN)
In particular i installed a PDF995 printer driver and i need to know where it is located to modify at runtime a pdf995.ini file.

It seems placed in c:\programs\pdf995 under w2000 but under XP i found it in c:\pdf995 (!).
and under Win9x ?

tks
Piscicelli/zingoni
Piscicelli Zingoni
 
Posts: 76
Joined: Wed Oct 12, 2005 5:52 pm
Location: Milan,Italy

Re: How to detect the programs folder

Postby Enrico Maria Giordano » Sat Feb 04, 2006 12:27 pm

Piscicelli Zingoni wrote:Hi, i forgot how to detect the standard folder programs, example C:\PROGRAMS (english) or
C:\PROGRAMMI (ITALIAN)


Code: Select all  Expand view
#define HKEY_CURRENT_USER  2147483649
#define HKEY_LOCAL_MACHINE 2147483650

#define KEY_ALL_ACCESS 983103


FUNCTION GETDESKDIR()

    LOCAL hKey := 0

    LOCAL nType := 0

    LOCAL cData := SPACE( 256 )

    LOCAL nSize := LEN( cData )

    REGOPENKEY( HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", 0, KEY_ALL_ACCESS, @hKey )

    REGQUERYVALUE( hKey, "Desktop", 0, @nType, @cData, @nSize )

    REGCLOSEKEY( hKey )

    RETURN LEFT( cData, AT( CHR( 0 ), cData ) - 1 )


FUNCTION GETPROGDIR()

    LOCAL hKey := 0

    LOCAL nType := 0

    LOCAL cData := SPACE( 256 )

    LOCAL nSize := LEN( cData )

    IF !ISWINNT()
        REGOPENKEY( HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", 0, KEY_ALL_ACCESS, @hKey )
        REGQUERYVALUE( hKey, "Programs", 0, @nType, @cData, @nSize )
    ELSE
        REGOPENKEY( HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", 0, KEY_ALL_ACCESS, @hKey )
        REGQUERYVALUE( hKey, "Common Programs", 0, @nType, @cData, @nSize )
    ENDIF

    REGCLOSEKEY( hKey )

    RETURN LEFT( cData, AT( CHR( 0 ), cData ) - 1 )


DLL32 FUNCTION REGOPENKEY( hKey AS LONG, cSubKey AS LPSTR, nOptions AS DWORD, nSamDesired AS DWORD, @nHandle AS PTR ) AS LONG;
      PASCAL FROM "RegOpenKeyExA" LIB "advapi32.dll"

DLL32 FUNCTION REGQUERYVALUE( hKey AS LONG, cValueName AS LPSTR, nReserved AS LONG, @nType AS PTR, @cData AS LPSTR, @nSize AS PTR ) AS LONG;
      PASCAL FROM "RegQueryValueExA" LIB "advapi32.dll"

DLL32 FUNCTION REGCLOSEKEY( hKey AS LONG ) AS LONG;
      PASCAL FROM "RegCloseKey" LIB "advapi32.dll"


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8356
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Piscicelli Zingoni » Sat Feb 04, 2006 1:16 pm

Questa non mi vanno bene perche' mi dicono dove e' il folder del menu' avvio\programmi.
Forse ho posto io male la domanda: installando il pdf995 non mi chiede nessuna conferma di cartella di installazione ma crea su c:\programmi\pdf995 (cartella) dove mette dentro il programma mentre in
C:\Documents and Settings\All-Users\Menu Avvio\Programmi mette altre cose (link htm) a me interessa sapere DI C:\PROGRAMMI (se italiano) o C:\PROGRAMS (se inglese) ecc.. insomma dove si trova effettivamente il software.

Per un possibile test puoi scaricarti da www.pdf995.com (area download) pdf995 Printer Driver e il Free Converter

Grazie
Piscicelli Zingoni
 
Posts: 76
Joined: Wed Oct 12, 2005 5:52 pm
Location: Milan,Italy

Postby Enrico Maria Giordano » Sat Feb 04, 2006 1:19 pm

Piscicelli Zingoni wrote:Questa non mi vanno bene perche' mi dicono dove e' il folder del menu' avvio\programmi.


No, le funzioni che ti ho messo sono due. Quella che serve a te è la GETPROGDIR().

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8356
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 31 guests