Windows operating system registry is stored in the system's hardware information, applications, information and user information in a database, which provides for the application the best place to save the parameter settings.In the Windows operating system, when we run "RegEdit.exe" files from the Registry Editor window opens you can see, the registry from the left and right parts: the first layer is called the left side of the registry's purposeprimary key, double-click the primary key of each key is called an extension of the sub-key; window on the right is the key of the sub-keys, each key has its corresponding sub-default values and use different key name that the keyvalue (the default value of which is named an empty string keys).
Read and write in VFP application registry data requires the use of WIN32API (ie Windows 32 bit application program interface) functions, in order to function the same as with the other VFP call WIN32API function, you must first use the DECLARE command for each function to be called up (in), the format DECLARE [cFunctionType] FunctionName IN LibraryName [AS AliasName];
[CParamType1 [@] ParamName1, cParamType2 [@] ParamName2, ...]
In which the meaning of the parameters is: ① cFunctionType as the return value type, but SHORT, INTEGER or LONG, SINGLE, DOUBLE, STRING one, if the function has no return value, omit cFunctionType; ② FunctionName that called WIN32API function name, please notecase, or in VFP. DLL library (LibraryName) less than the search function and error, if the function name with the same name as a function of VFP, AS clause can also take a legal VFP function name; ③ LibraryName specify an external Windows.DLL name, such as taking WIN32API, the VFP in KERNEL32.DLL, GDI32.DLL, USER32.DLL, MPR.DLL and ADVAPI32.DLL search FunctionName; ④ cParamType specify the type of each parameter, can be INTEGER or LONG, SINGLE,DOUBLE, STRING, one of the VFP to pass parameters to the function in two ways: by value and by name (reference) is passed, the former only the variable (also constant) value to the function, so inside the functioncan not modify the value of the variable; the latter is the variable (not constant) the address to the function, which can be modified within the function the value of the variable for the function needs to modify the variable value inside or placed in a variablereturn value of the situation.VFP in front of the variable name as "@" that pass parameters by reference, without "@" that pass parameters by value.For this example, the parameters of the program is passed by reference or by value, commands and function calls from the DECLARE statement, see at a glance.
The following sample program to run every time, it will be in the registry subkey TimesForUse HKEY_CURRENT_USERSOFTWARELYTAPP name value plus 1, until the run 12 times so far:
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only the primary key and an integer (INTEGER) value corresponds to, namely:
# DEFINE HKEY_CLASSES_ROOT bitset (0,31) & & -2147483648
# DEFINE HKEY_CURRENT_USER bitset (0,31) +1 & & -2147483647
# DEFINE HKEY_LOCAL_MACHINE bitset (0,31) +2 & & -2147483646
# DEFINE HKEY_USER bitset (0,31) +3 & & -2147483645
# DEFINE HKEY_CURRENT_CONFIG bitset (0,31) +5 & & -2147483643
# DEFINE HKEY_DYN_DATA bitset (0,31) +6 & & -2147483642
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only key data types: 1 - string, 3 - binary, 4 - Integer
# DEFINE REG_SZ 1
# DEFINE REG_BINARY 3
# DEFINE REG_DWORD 4
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only when the following API function returns 0, the operation was successful.
DECLARE Integer RegOpenKey IN Win32API;
Integer nHKey, String @ cSubKey, Integer @ nResult
DECLARE Integer RegCreateKey IN Win32API;
Integer nHKey, String @ cSubKey, Integer @ nResult
DECLARE Integer RegSetValueEx IN Win32API;
Integer hKey, String lpszValueName, Integer dwReserved,;
Integer fdwType, String lpbData, Integer cbData
DECLARE Integer RegQueryValueEx IN Win32API;
Integer nHKey, String lpszValueName, Integer dwReserved,;
Integer @ lpdwType, string @ lpbData, Integer @ lpcbData
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only DECLARE Integer RegDeleteKey IN Win32API;
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only Integer nHKey, String @ cSubKey
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only DECLARE Integer RegDeleteValue IN Win32API;
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only Integer nHKey, String cSubKey
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only DECLARE Integer RegCloseKey IN Win32API;
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only Integer nHKey
csubkey =''Softwarelytapp''
nresult = 0
if regopenkey (HKEY_CURRENT_USER, @ csubkey, @ nresult) # 0
RegCreateKey (HKEY_CURRENT_USER, csubkey, @ nresult)
endif
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news:15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only store in nresult a point in the sub-key "HKEY_CURRENT_USERSoftwarelytapp" long integer value
lpdwtype = 0
lpbdata = space (256)
lpcbdata = len (lpbdata)
if RegQueryValueEx (nresult,''TimesForUse'', 0, @ lpdwtype, @ lpbdata, @ lpcbdata) = 0
do case
case lpdwtype = REG_SZ
lpbdata = left (lpbdata, lpcbdata-1)
if val (lpbdata) <12
lpbdata = alltrim (str (val (lpbdata) +1))
messagebox (''until the program is not registered can only use 12 times!''+ CHR (13) +''''You are the +;
lpbdata +''-use of this procedure.'')
lpbdata = lpbdata + chr (0)
cbdata = len (lpbdata)
RegSetValueEx (nresult,''TimesForUse'', 0, REG_SZ, lpbdata, cbdata)
else
messagebox ("program has expired!" + CHR (13) + "please contact the registration.")
endif
case lpdwtype = REG_BINARY
messagebox (''the key as binary data.'')
case lpdwtype = REG_DWORD
messagebox (''The key to a long integer data, please use the NN = 0''+ CHR (13) +''for i = 1 to 4''+ CHR (13) +;
''NN = NN + VAL (SUBSTR (lpbdata, i, 1) * 16 ^ (2 * i-2)''+ CHR (13) +;
''Endfor read this value.'')
otherwise
messagebox (''Unknown data!'')
endcase
else
lpbdata =''1''
messagebox (''until the program is not registered can only use 12 times!''+ CHR (13) +''You are the first''+ lpbdata +''-use of the program.'')
lpbdata = lpbdata + chr (0)
RegSetValueEx (nresult,''TimesForUse'', 0, REG_SZ, lpbdata, 2)
endif
* Warning: when the user is not familiar with the registry is best not to modify the content, otherwise, may result in system crashes.If the user wants to modify the registry, it is recommended to modify the registry backup before the best.