registry sample

registry sample

Postby Nop » Wed Mar 14, 2007 6:54 pm

hi, someone has an simple sample to write to windows registry? thanks
User avatar
Nop
 
Posts: 107
Joined: Tue Apr 11, 2006 4:36 pm
Location: Uberaba/Brazil

Re: registry sample

Postby Enrico Maria Giordano » Wed Mar 14, 2007 9:02 pm

Code: Select all  Expand view
#define HKEY_CURRENT_USER 2147483649

#define KEY_ALL_ACCESS 983103

#define REG_SZ 1


STATIC FUNCTION PDFGETOPTION( cKey )

    LOCAL hKey := 0

    LOCAL nType := REG_SZ

    LOCAL cData := SPACE( 256 )

    LOCAL nSize := LEN( cData )

    REGOPENKEY( HKEY_CURRENT_USER, "Software\PDFCreator\Program", 0, KEY_ALL_ACCESS, @hKey )

    REGQUERYVALUE( hKey, cKey, 0, @nType, @cData, @nSize )

    REGCLOSEKEY( hKey )

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


STATIC FUNCTION PDFSETOPTION( cKey, cValue )

    LOCAL hKey := 0

    LOCAL nType := REG_SZ

    LOCAL nSize := LEN( cValue )

    REGOPENKEY( HKEY_CURRENT_USER, "Software\PDFCreator\Program", 0, KEY_ALL_ACCESS, @hKey )

    REGSETVALUE( hKey, cKey, 0, nType, cValue, nSize )

    REGCLOSEKEY( hKey )

    RETURN NIL


DLL32 STATIC 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 STATIC 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 STATIC FUNCTION REGSETVALUE( hKey AS LONG, cValueName AS LPSTR, nReserved AS LONG, nType AS DWORD, cData AS LPSTR, nData AS DWORD ) AS LONG;
      PASCAL FROM "RegSetValueExA" LIB "advapi32.dll"

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


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

Postby Nop » Thu Mar 15, 2007 2:01 am

Enrico, thanks.
User avatar
Nop
 
Posts: 107
Joined: Tue Apr 11, 2006 4:36 pm
Location: Uberaba/Brazil

Postby James Bott » Thu Mar 15, 2007 2:44 am

Nop,

Be sure to check out the new security issues with writing to the registry under Vista. Here is a good place to start:

http://windowsconnected.com/blogs/jerry ... 19/86.aspx

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 70 guests