码迷,mamicode.com
首页 > 其他好文 > 详细

计算机病毒揭秘与对抗--注册表操作2

时间:2016-03-20 21:06:15      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:


  1. // RegCreateValue.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <stdio.h>
  5. #include <tchar.h>
  6. #include <Windows.h>
  7. int main(int argc, char* argv[])
  8. {
  9. HKEY hSubKey;
  10. //以KEY_SET_VALUE权限打开HKEY_CURRENT_USER\ Control Panel键的句柄
  11. LONG ReturnValue = RegOpenKeyEx (HKEY_CURRENT_USER, "Control Panel",
  12. 0L, KEY_SET_VALUE, &hSubKey);
  13. DWORD dwValue = 0xff;
  14. if (ReturnValue == ERROR_SUCCESS)
  15. {
  16. ReturnValue = RegSetValueEx(hSubKey, "test", 0, REG_DWORD, (BYTE *)&dwValue, sizeof(DWORD));
  17. if (ReturnValue == ERROR_SUCCESS)
  18. {
  19. printf("设置成功");
  20. }
  21. else
  22. {
  23. printf("设置失败");
  24. }
  25. }
  26. return 0;
  27. }
技术分享





计算机病毒揭秘与对抗--注册表操作2

标签:

原文地址:http://www.cnblogs.com/hungryvampire/p/5299293.html

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