Wednesday, September 17, 2014

Visual C++ 레지스트리 예제

#include "stdafx.h"
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
 wchar_t* subkey = L"Software\\RegistryTest";
 HKEY key = NULL;
 LONG ret = RegOpenKey(HKEY_LOCAL_MACHINE, subkey, &key);

 if(ret != ERROR_SUCCESS)
 {
  RegCreateKey(HKEY_LOCAL_MACHINE, subkey, &key);
 }

 wchar_t* valueName = L"fps";
 int data = 58;

 RegSetKeyValue(HKEY_LOCAL_MACHINE, subkey, valueName, REG_DWORD, &data, sizeof(int));

 DWORD dwType;
 int retData;
 DWORD cbData;

 RegGetValue(HKEY_LOCAL_MACHINE, subkey, valueName, RRF_RT_DWORD, &dwType, &retData, &cbData);

 RegCloseKey(key);

 return 0;
}

No comments:

Post a Comment