Article ID: 140170
Article Last Modified on 7/1/2004
135398 How To Write to the Windows Registry Using API Calls
***
***BEGIN PROGRAM CODE
***
nKeyHandle=0 && Holds the handle to the key opened by RegOpenKey
iValue=0 && Index of value to query
lpszValue=space(255) && Receives the name of the value
* In this example, you are looking for TMPFILES.
lpcchValue=255
* This buffer tells the API the size of the lpszValue buffer.
* If buffer is not large enough, the lpszValue buffer will be blank.
lpdwType=space(255) && Receives the type code for the value entry
lpbData=space(255) && Receives the data for the value entry
* In this example, it will contain the path to the TMPFILES.
lpcbData=255 && This buffer tells the API the size of the lpbData buffer
* If lpbData is not large enough, the buffer will be blank.
Declare RegOpenKey in ADVAPI32.DLL INTEGER, STRING, INTEGER @nKeyHandle
Declare RegEnumValue in ADVAPI32.DLL INTEGER nKeyHandle, INTEGER iValue,;
STRING @lpszValue, INTEGER @lpcchValue, INTEGER, STRING @lpdwType, ;
STRING @lpbData, INTEGER @lpcbData
** The number for the HKey_Current_User (the first parameter in RegOpenKey)
** is found in the Winreg.h header file included with Microsoft Visual C++
=RegOpenKey(2147483649,"Software\Microsoft\VisualFoxPro\3.0\Options",;
@nKeyHandle)
do while alltrim(lpszValue)!="TMPFILES" &&loops through the key looking
* for TMPFILES
lpszValue=space(255) &&need to reset the buffers
lpcchValue=255
lpdwType=space(255)
lpbData=space(255)
lpcbData=255
=RegEnumValue(nKeyHandle,iValue,@lpszValue,@lpcchValue,0,;
@lpdwType,@lpbData,@lpcbData)
?alltrim(lpbData)+ ' '+alltrim(lpszValue)
iValue=iValue+1
enddo
** END PROGRAM CODE **
Additional query words: Foxuser temp resource spellchk
Keywords: kbcode KB140170