Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Difference between NT & 95 registry?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00082028
Message ID:
00082039
Views:
26
There are differences; many of these center on the security permissions flags passed in the various API calls. The following code works to write registry values in both Win95 and NT: Creating/ opening a registry key - uses RegCreateKey() DECLARE INTEGER RegCreateKey IN Win32API ; INTEGER nhKey, ; STRING @cSubKey, ; INTEGER @nKeyHandle #define HKEY_LOCAL_MACHINE -2147483646 && 1*(bitset(0,31)+2) *// Key options: #define REG_OPTION_RESERVED 0 && Parameter is reserved #define REG_CLASS_DEFAULT "" && Default key class #define REG_SECURITY_DEFAULT 0 && Default security descriptor #define REG_OPTION_NON_VOLATILE 0 && Key is preserved when system is rebooted #define REG_OPTION_VOLATILE 1 && Key is not preserved when system is rebooted *// Security Access Masks: #define KEY_QUERY_VALUE 1 #define KEY_SET_VALUE 2 #define KEY_CREATE_SUB_KEY 4 #define KEY_ENUMERATE_SUB_KEYS 8 #define KEY_NOTIFY 16 #define KEY_CREATE_LINK 32 #define KEY_READ KEY_QUERY_VALUE + KEY_ENUMERATE_SUB_KEYS + KEY_NOTIFY #define KEY_WRITE KEY_SET_VALUE + KEY_CREATE_SUB_KEY #define KEY_ALL_ACCESS KEY_READ + KEY_WRITE + KEY_CREATE_LINK * * cKey is the string value of a key relative to HKEY_LOCAL_MACHINE * m.nResult = RegCreateKey( HKEY_LOCAL_MACHINE, ; m.cKey + CHR(0), ; @nNewKey ) m.nCurrentKey = nNewKey Creating a value under the currently open key: DECLARE INTEGER RegSetValueEx IN Win32API ; INTEGER nKeyHandle, ; STRING cValueName, ; INTEGER nReserved, ; INTEGER nType, ; STRING cBuffer, ; INTEGER nBufferSize * * Assume we're writing a value of type REG_SZ (a null-terminated string) * *// Value Types: #define REG_NONE 0 && No value type #define REG_SZ 1 && Unicode nul terminated string #define REG_EXPAND_SZ 2 && Unicode null terminated string #define REG_BINARY 3 && Free form binary #define REG_DWORD 4 && 32-bit number #define REG_DWORD_LITTLE_ENDIAN 4 && 32-bit number (same as REG_DWORD) #define REG_DWORD_BIG_ENDIAN 5 && 32-bit number #define REG_LINK 6 && Symbolic Link (unicode) #define REG_MULTI_SZ 7 && Multiple Unicode strings #define REG_RESOURCE_LIST 8 && Resource list in the resource map #define REG_FULL_RESOURCE_DESCRIPTOR 9 && Resource list in the hardware desc #define REG_RESOURCE_REQUIREMENTS_LIST 10 && m.nType = REG_SZ m.cValueName = "MyNewValueID" m.cNewValue = m.cNewValue + CHR(0) nResult = RegSetValueEx( ; m.nCurrentKey, ; m.cValueName, ; REG_OPTION_RESERVED, ; m.nType, ; m.cNewValue, ; LEN(m.cNewValue) -1 ) > >Does anybody know of any difference between 95 and NT registry calling? I have written a number of programs to read from and write to the Windows 95 registry and all works ok! When I tried these programs on my NT PC, nothing happened - nothing returned from registry and nothing written to registry. I made the entries manually and tried reading them but nothing was returned?? > Attachment Converted: Edward M Rauh.vcf
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform