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
|
HKEY hk;
int result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_T("SYSTEMControlSet001ControlSession ManagerEnvironment"),
NULL,
KEY_READ, &hk );
if(result != ERROR_SUCCESS)
{
if(result == ERROR_FILE_NOT_FOUND)
{
MessageBox(g.hwnd,_T("no such key in RegOpenKeyEx"),_T("title"),MB_ICONWARNING);
}
else
return;
}
DWORD lsize;
result = RegQueryValueEx(hk, _T("Path"),NULL,NULL,
NULL, &lsize);
if(result != ERROR_SUCCESS)
{
if(result == ERROR_FILE_NOT_FOUND)
{
MessageBox(g.hwnd,_T("no such key in RegQueryValue"),_T("title"),MB_ICONWARNING);
}
else if(result == ERROR_MORE_DATA)
{
MessageBox(g.hwnd,_T("need more buffer"),_T("title"),MB_ICONWARNING);
}
else
return;
}
TCHAR *value = (TCHAR * )malloc(lsize * sizeof(TCHAR));
result = RegQueryValueEx(hk, _T("Path"),NULL,NULL,
(LPBYTE)value, &lsize);
if(result != ERROR_SUCCESS)
{
if(result == ERROR_FILE_NOT_FOUND)
{
MessageBox(g.hwnd,_T("no such key in RegQueryValue"),_T("title"),MB_ICONWARNING);
}
else if(result == ERROR_MORE_DATA)
{
MessageBox(g.hwnd,_T("need more buffer"),_T("title"),MB_ICONWARNING);
}
else
return;
}
SetWindowText(g.hwndEdit,value);
free(value);
RegCloseKey(hk);
|