Hi all!
Here is my problem.
Got registry unter HKLM\SOFTWARE\A.
Now I want to create symlink to this key. in HKLM\SOFTWARE__symlink__
So I’ve prepared following code:
HKEY key;
int res;
DWORD dispo;
TCHAR linkname = “SOFTWARE_symlink_”;
TCHAR linkto = “\Registry\MACHINE\SOFTWARE\A”;
res = RegCreateKeyEx( HKEY_LOCAL_MACHINE, linkname, 0, NULL, REG_OPTION_VOLATILE|REG_OPTION_CREATE_LINK,
KEY_ALL_ACCESS | KEY_CREATE_LINK , NULL, &key, &dispo);
if (ERROR_SUCCESS == res)
{
res = RegSetValueEx(key, “SymbolicLinkValue”, 0, REG_LINK, (LPBYTE)link, lstrlen(link)*sizeof(WCHAR));
if (ERROR_SUCCESS == res)
{
printf(“link created\n”);
}
else
{
printf(“link not created %d\n”, res);
}
RegCloseKey(key);
}
else
{
printf(“error %d\n”, res);
}
res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, b, 0, NULL, REG_OPTION_VOLATILE,
KEY_ALL_ACCESS , NULL, &key, &dispo);
if (ERROR_SUCCESS == res)
{
printf(“OK!\n”);
}
else
{
printf(“error %d”, res);
}
Now - output for this code is:
link created
error 2
Error is ERROR_FILE_NOT_FOUND.
When I’m going to regedit and click on my symlink key I see message box: “Error while opening key”.
Can somebody tell me what’s wrong with this code?
I would like to open symlink, perform some actions on it and see results in original registry…
Thank you for any comment here.