Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need Help with WIN32API
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Need Help with WIN32API
Divers
Thread ID:
00210462
Message ID:
00210462
Vues:
90
I thought I had a handle on this, but I having trouble with this one
*-- DECLARE DLL statements for reading/writing to system registry
DECLARE Integer RegOpenKeyEx IN Win32API ;
  Integer nKey, String @cSubKey, Integer nReserved,;
  Integer nAccessMask, Integer @nResult
 
DECLARE Integer RegQueryValueEx IN Win32API ;
  Integer nKey, String cValueName, Integer nReserved,;
  Integer @nType, String @cBuffer, Integer @nBufferSize

DECLARE Integer RegCloseKey IN Win32API ;
  Integer nKey

CLEAR

STORE 0 TO lnReserved, lnResult, lnType

IF NOT (UPPER(OS()) = "WINDOWS NT" OR UPPER(OS()) = "WINDOWS 4")
  *I'm lazy and don't feel like checking other OS's right now
  =MESSAGEBOX("Only Compatiable With Windows NT") 
  CANCEL
ELSE
       
  lcMyKey = "Software\The Commonwealth Group\"
    
  lcThisKey = lcMyKey + "Test Key 1"
  lcQueryLabel = "Val 1"
    
  lnError = RegOpenKeyEx(HKEY_CURRENT_USER, ;
          lcThisKey, lnReserved, KEY_QUERY_VALUE, @lnResult)
    
    IF lnError = ERROR_SUCCESS  && This always works

      lcBuffer = SPACE(128)
      lnBufferSize = LEN(lcBuffer)
      
      * and this always works
      lnError = RegQueryValueEx(lnResult, lcQueryLabel , lnReserved, ;
                                @lnType, @lcBuffer, @lnBufferSize)
                              
      IF lnError = ERROR_SUCCESS
        lcValue = ALLT(LEFT(lcBuffer, lnBufferSize)) 
      ENDIF
      
      lcBuffer = "New Value"
      lnBufferSize = LEN(lcBuffer)+10
      
      DECLARE Integer RegSetValueEx IN Win32API ;
         Integer nKey, String @cValueName, Integer nReserved, ;
         Integer nType, String @cBuffer, Integer nBufferSize
      
      * This returns a 5, always, I've tried using the '@' in various 
      * combinations but I get the same result.
      IF lnError = ERROR_SUCCESS
        lnError = RegSetValueEx(lnResult, lcQueryLabel, lnReserved, ;
                                lnType, lcBuffer, lnBufferSize)
      ENDIF                              

      IF lnError = ERROR_SUCCESS
        lnError = RegQueryValueEx(lnResult, lcQueryLabel , lnReserved, ;
                                  @lnType, @lcBuffer, @lnBufferSize)
                              
        IF lnError = ERROR_SUCCESS
          lcValue = ALLT(LEFT(lcBuffer, lnBufferSize)) 
        ENDIF
        
      ELSE
        =Messagebox("NOPE")
      ENDIF
      
   ENDIF

    *-- Close the key
    =RegCloseKey(lnResult)

ENDIF

CLEAR DLLS
CLEAR ALL
RELEASE ALL EXTENDED
P.S. It's good to be back. I missed all of you.
I try to stay online, to get better information.
I try to get away from the office once in a while..
But they KEEP... PULLING.. ME.. BACK.. IN!!!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform