码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2016-11-20 16:01:44      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:sys   turn   写入   open   current   pac   str   main   result   

#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;
}

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

标签:sys   turn   写入   open   current   pac   str   main   result   

原文地址:http://www.cnblogs.com/xuandi/p/6082691.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!