From: Eric K. <ek...@rz...> - 2002-06-18 13:40:25
|
Hi! One of the most mysterious details of the registry has been uncovered, the registry link. Didn't you ever wonder what this REG_LINK value type is used for? Or what about the key access right KEY_CREATE_LINK? At least one registry link is used in Windows NT/2K/XP. "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet" is a link to one of the "HKEY_LOCAL_MACHINE\SYSTEM\ControlSetXXX" keys (XXX can be any three digit number, starting at 001). The available documentation does not provide any useful information about registry links other than trivial statements, like: 'A registry link is a link to link registry keys.' On the net, I found a posting about someones unsuccessful attempt to create a registry link. This was the only useful information I found. After some extensive research I got it working: Let's assume you have a existing key "HKEY_LOCAL_MACHINE\SOFTWARE\SMT" and the new key "HKEY_LOCAL_MACHINE\SOFTWARE\Test\Link" should point to it. Then the following code will do the trick: HKEY hKeyHandle; DWORD dwDisposition; DWORD dwLength; PWCHAR ValueName = L"SymbolicLinkValue"; PWCHAR Buffer= L"\\Registry\\Machine\\SOFTWARE\\SMT"; /* create the key */ RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Test\\Link", 0, NULL, REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, KEY_ALL_ACCESS | KEY_CREATE_LINK, NULL, &hKeyHandle, &dwDisposition); /* Note: length WITHOUT the terminating zero */ dwLength = wcslen(Buffer) * sizeof(WCHAR); /* set the link value */ RegSetValueExW(hKeyHandle, ValueName, 0, REG_LINK, (const BYTE *)Buffer, dwLength); RegCloseKey(hKeyHandle); I still have to find out whether registry links can be removed or changed. Regards, Eric |