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


  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. }






posted @ 2016-03-20 19:22  hungryvampire  阅读(435)  评论(0编辑  收藏  举报