Cover | Table of Contents | Colophon
Everyone:Read paul:Full Control Engineering:Full Control
|
Permission
|
|---|
// Hello, World! for the Registry: gets this machine's name and prints
// it out.
#include <windows.h>
#include <winreg.h>
#include <stdio.h>
void main(void)
{
unsigned char lpName[MAX_PATH] = "";
DWORD nNameLen = MAX_PATH;
HKEY hkResult, hStartKey = HKEY_LOCAL_MACHINE;
LONG nResult = ERROR_SUCCESS;
nResult = RegOpenKeyEx(hStartKey,
"SYSTEM\\CurrentControlSet\\Control\\ComputerName",
0L, KEY_READ, &hkResult);
if (ERROR_SUCCESS == nResult)
{
nResult = RegQueryValueEx(hkResult, "ActiveComputerName", 0, 0,
lpName, &nNameLen);
if (ERROR_SUCCESS == nResult)
printf("Hello, world, from %s!", lpName);
}
RegCloseKey(hkResult);
}
http://www.drj.com). Instead, I'll
present two simple concepts that will save your bacon if you
implement them. While they're targeted at helping you recover
from Registry failures, you can also apply them to other situations
that might render your Windows 2000 machines (or any others, really)
unusable or unavailable.
|
Key
|
When Used in...
|
Action
|
|---|---|---|
|
Tab
|
Key or value panes
|
Switches focus between the key and value panes
|
|
Return
|
Value pane
|
Opens selected item for editing
|
|
Up/down arrows
|
Key or value panes
|
Moves focus to the next or previous item in the current pane
|
|
Left/right arrows
|
Key pane
|
If selected item has subkeys, expands (left arrow) or collapses
(right arrow) it; if not, moves to next or previous item |
REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser] "Type"=dword:00000020 "Start"=dword:00000002 "ErrorControl"=dword:00000001 "ImagePath"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,53,79,73, \ 74,65,6d,33,32,5c,73,65,72,76,69,63,65,73,2e,65,78,65,00 "DisplayName"="Computer Browser" "DependOnService"=hex(7):4c,61,6e,6d,61,6e,57,6f,72,6b,73,74,61,74,69, \ 6f,6e,00,4c,61,6e,6d,61,6e,53,65,72,76,65,72,00,4c,6d,48,6f,73,74, \ 73,00,00 "DependOnGroup"=hex(7):00 "ObjectName"="LocalSystem" [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser\Linkage] [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser\Linkage\Disabled] [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser\Parameters] "MaintainServerList"="Auto" "IsDomainMaster"="FALSE"
/e
command-line switch. The command looks like this:regedit /e targetFile [registryPath]
regedit /e c:\dist\hklm\warrior.reg HKEY_LOCAL_MACHINE\SOFTWARE\metrowerks
regedit warrior.reg