I'll put this together as an FAQ in the near future and it will be a bit more clear, but here it is to get you going.
This code assumes you have vfp 7.0 installed. If not, change the 7.0 to your version.
Just copy all this code in a prg and run it. It will return the product ID in a messagebox.
bCode Below Here:
PUBLIC goApp
goApp = CREATEOBJECT('capp')
MESSAGEBOX(goApp.ReadReg('HLM','Software\Microsoft\VisualFoxpro\7.0\Registration','ProductID'))
**************************************************
*
DEFINE CLASS capp AS container
*-- Reads the windows Registry.
PROCEDURE readreg
* Start of Code
LPARAMETERS tcKey,tcSubKey,tcValue
IF PCOUNT() = 2
tcValue = ""
ENDIF
* setup environment
LOCAL nKey, cSubKey, cValue, cValueRead
#DEFINE HKEY_USERS -2147483645
#DEFINE HKEY_LOCAL_MACHINE -2147483646
#DEFINE HKEY_CURRENT_USER -2147483647
#DEFINE HKEY_CLASSES_ROOT -2147483648
DO CASE
CASE m.tcKey == "HCR"
nKey = HKEY_CLASSES_ROOT
CASE m.tcKey == "HLM"
nKey = HKEY_LOCAL_MACHINE
CASE m.tcKey = "HCU"
nKey = HKEY_CURRENT_USER
CASE m.tcKey = "HCR"
nKey = HKEY_CLASSES_ROOT
OTHERWISE
nKey = m.tcKey
ENDCASE
cSubKey = m.tcSubKey
cValue = m.tcValue
* example 1
* nKey = HKEY_LOCAL_MACHINE
* cSubKey = "Software\VfpRegTest"
* cValue = "TestREG_SZ"
* example 2
* nKey = HKEY_CLASSES_ROOT
* cSubKey = "Spin.SpinButton\CLSID"
* cValue = ""
* here is where we will actually read the registry
cValueRead = THIS.ReadREG_SZ(nKey, cSubKey, cValue)
* testing only
IF (EMPTY(cValueRead)) THEN
* THIS.STOP("Function Not Successful."

ELSE
* THIS.INFO("Function Successful. " + cValueRead)
ENDIF
RETURN cValueRead
ENDPROC
*-- API's used by the ReadReg method.
PROCEDURE readreg_sz
* This function reads a REG_SZ value from the registry. If successful,
* it will return the value read. If not successful, it will return an empty string.
PARAMETERS nKey, cSubKey, cValue
* nKey The root key to open. It can be any of the constants defined below.
* #DEFINE HKEY_CLASSES_ROOT -2147483648
* #DEFINE HKEY_CURRENT_USER -2147483647
* #DEFINE HKEY_LOCAL_MACHINE -2147483646
* #DEFINE HKEY_USERS -2147483645
* cSubKey The SubKey to open.
* cValue The value that is going to be read.
* Constants that are needed for Registry functions
#DEFINE REG_SZ 1
* WIN 32 API functions that are used
DECLARE Integer RegOpenKey IN Win32API ;
Integer nHKey, String @cSubKey, Integer @nResult
DECLARE Integer RegQueryValueEx IN Win32API ;
Integer nHKey, String lpszValueName, Integer dwReserved,;
Integer @lpdwType, String @lpbData, Integer @lpcbData
DECLARE Integer RegCloseKey IN Win32API Integer nHKey
* Local variables used
LOCAL nErrCode && Error Code returned from Registry functions
LOCAL nKeyHandle && Handle to Key that is opened in the Registry
LOCAL lpdwValueType && Type of Value that we are looking for
LOCAL lpbValue && The data stored in the value
LOCAL lpcbValueSize && Size of the variable
LOCAL lpdwReserved && Reserved Must be 0
* Initialize the variables
nKeyHandle = 0
lpdwReserved = 0
lpdwValueType = REG_SZ
lpbValue = ""
nErrCode = RegOpenKey(nKey, cSubKey, @nKeyHandle)
* If the error code isn't 0, then the key doesn't exist or can't be opened.
IF (nErrCode # 0) THEN
RETURN ""
ENDIF
lpcbValueSize = 1
* Get the size of the data in the value
nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)
* Make the buffer big enough
lpbValue = SPACE(lpcbValueSize)
nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)
=RegCloseKey(nKeyHandle)
IF (nErrCode # 0) THEN
RETURN ""
ENDIF
lpbValue = LEFT(lpbValue, lpcbValueSize - 1)
RETURN lpbValue
ENDPROC
ENDDEFINE
*
*-- EndDefine: capp
**************************************************
Jim Osieczonek
Delta Business Group, LLC