-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry.cpp
71 lines (61 loc) · 1.92 KB
/
registry.cpp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "StdAfx.h"
void ReadKey( HKEY hKey, const char* Section, const char* ValueName, UINT& Value, UINT DefValue )
{
HKEY hkResult;
DWORD size = sizeof(DWORD);
RegCreateKey( hKey, Section, &hkResult );
if ( RegQueryValueEx( hkResult, ValueName, 0, 0, (BYTE*)&Value, &size ) )
Value = DefValue;
RegCloseKey( hkResult );
}
void ReadKey( HKEY hKey, const char* Section, const char* ValueName, char** Value, DWORD size )
{
HKEY hkResult;
RegCreateKey( hKey, Section, &hkResult );
RegQueryValueEx( hkResult, ValueName, 0, 0, (BYTE*)Value, &size );
RegCloseKey( hkResult );
}
LONG ReadKey( HKEY hKey, const char* Section, const char* ValueName, BYTE** BinaryValue, DWORD* size )
{
HKEY hkResult;
RegCreateKey( hKey, Section, &hkResult );
LONG lRet = RegQueryValueEx( hkResult, ValueName, 0, 0, (BYTE*)BinaryValue, size );
RegCloseKey( hkResult );
return lRet;
}
/*
*
*
*/
void WriteKey( HKEY hKey, const char* Section, const char* ValueName, UINT Value )
{
HKEY hkResult;
RegCreateKey( hKey, Section, &hkResult );
RegSetValueEx( hkResult, ValueName, 0, REG_DWORD_LITTLE_ENDIAN, (BYTE*)&Value, sizeof(UINT) );
RegCloseKey( hkResult );
}
void WriteKey( HKEY hKey, const char* Section, const char* ValueName, char* Value )
{
HKEY hkResult;
RegCreateKey( hKey, Section, &hkResult );
RegSetValueEx( hkResult, ValueName, 0, REG_SZ, (BYTE*)Value, lstrlen(Value)+1 );
RegCloseKey( hkResult );
}
void WriteKey( HKEY hKey, const char* Section, const char* ValueName, BYTE* Value, int BinarySize )
{
HKEY hkResult;
RegCreateKey( hKey, Section, &hkResult );
RegSetValueEx( hkResult, ValueName, 0, REG_BINARY, (BYTE*)Value, BinarySize );
RegCloseKey( hkResult );
}
/*
*
*
*/
void DeleteKey( HKEY hKey, const char* Section, const char* ValueName )
{
HKEY hkResult;
RegOpenKeyEx(hKey,Section,0,KEY_ALL_ACCESS,&hkResult);
RegDeleteValue( hkResult, ValueName );
RegCloseKey( hkResult );
}