我试着使用注册表静默地安装Chrome扩展。当我手动将键推送到Computer\HKEY_CURRENT_USER\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist键值:gighmmpiobklfepjocnamgkkbiglidom;https://clients2.google.com/service/update2/crx时,它确实有效。是个阻滞剂。
当我对我的C程序做同样的事情时,它不会把新的键推到想要的位置。当我搜索整个注册表时,键被推入一个非常不同的位置。键被推送到注册表中的这个位置:Computer\HKEY_USERS\S-1-5-21-2801756348-263109946-2004673029-1002\Computer\HKEY_CURRENT_USER\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist。
如何在不将注册表项推入不同位置的情况下成功地推送注册表项?
#include <stdio.h>
#include <Windows.h>
int main()
{
HKEY key;
int r = RegCreateKeyExA(HKEY_CURRENT_USER, "Computer\\HKEY_CURRENT_USER\\SOFTWARE\\Policies\\Google\\Chrome\\ExtensionInstallForcelist",
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL);
if (r != ERROR_SUCCESS)
{
printf("error\n");
}
r = RegSetKeyValueA(key, NULL, "1", REG_SZ, "gighmmpiobklfepjocnamgkkbiglidom;https://clients2.google.com/service/update2/crx", 100);
if (r != ERROR_SUCCESS)
{
printf("error 2\n");
}
RegCloseKey(key);
}发布于 2022-04-17 00:11:32
创建键时,将HKEY_CURRENT_USER传递给hKey参数,但也将HKEY_CURRENT_USER放在路径中,这需要HKEY_CURRENT_USER的一个子项。尝试使用"SOFTWARE\\Policies\\Google\\Chrome\\ExtensionInstallForcelist"代替。
https://stackoverflow.com/questions/71898195
复制相似问题