forked from somma/_MyLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_test_registry_util.cpp
More file actions
54 lines (44 loc) · 1.71 KB
/
_test_registry_util.cpp
File metadata and controls
54 lines (44 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**----------------------------------------------------------------------------
* _test_registry_util.cpp
*-----------------------------------------------------------------------------
*
*-----------------------------------------------------------------------------
* All rights reserved by Noh,Yonghwan (fixbrain@gmail.com, unsorted@msn.com)
*-----------------------------------------------------------------------------
* 2014:9:24 21:10 created
**---------------------------------------------------------------------------*/
#include "stdafx.h"
#include "RegistryUtil.h"
/**
* @brief
* @param
* @see
* @remarks
* @code
* @endcode
* @return
**/
bool test_registry_util()
{
// Create key
HKEY key = RUCreateKey(HKEY_CURRENT_USER, L"_test_key", false);
if (NULL == key) return false;
RegCloseKey(key);
// key created ?
if (true != RUIsKeyExists(HKEY_CURRENT_USER, L"_test_key")) return false;
// write dword value
if (true != RUWriteDword(HKEY_CURRENT_USER, L"_test_key", L"TestValue", 1000)) return false;
// write string
if (true != RUSetString(HKEY_CURRENT_USER, L"_test_key", L"TestValueString", L"abc", (DWORD)((wcslen(L"abc") + 1) * sizeof(wchar_t))) ) return false;
// read dword value
if (1000 != RUReadDword(HKEY_CURRENT_USER, L"_test_key", L"TestValue", 0)) return false;
std::wstring str;
if (true != RUReadString(HKEY_CURRENT_USER, L"_test_key", L"TestValueString", str)) return false;
if (0 != str.compare(L"abc")) return false;
// Delete DWORD Value
if (true != RUDeleteValue(HKEY_CURRENT_USER, L"_test_key", L"TestValue")) return false;
// Delete key
// -- key ³»ºÎÀÇ value µéµµ ÇÔ²² »èÁ¦µÊ
if (true != RUDeleteKey(HKEY_CURRENT_USER, L"_test_key")) return false;
return true;
}