1 | #include <cstdlib>
|
2 | #include <iostream>
|
3 | #include <string.h>
|
4 |
|
5 | #include <windows.h>
|
6 | #include <Winreg.h>
|
7 |
|
8 |
|
9 |
|
10 | using namespace std;
|
11 |
|
12 | bool getreg();
|
13 |
|
14 | int main(int argc, char *argv[])
|
15 | {
|
16 |
|
17 | getreg();
|
18 |
|
19 | system("PAUSE");
|
20 | return EXIT_SUCCESS;
|
21 | }
|
22 |
|
23 | bool getreg()
|
24 | {
|
25 |
|
26 | HKEY hKey = HKEY_LOCAL_MACHINE;
|
27 | LPCTSTR subKey = "HARDWARE\\DEVICEMAP\\SERIALCOMM";
|
28 | REGSAM samDesired = KEY_READ;
|
29 | HKEY Result;
|
30 |
|
31 | DWORD dwIndex = 0;
|
32 | char lpValueName[MAX_PATH];
|
33 | DWORD lpcValueName = MAX_PATH;
|
34 | BYTE lpData[1024];
|
35 | DWORD lpcbData = MAX_PATH;
|
36 | // char chName[MAX_PATH];
|
37 |
|
38 | long ret = RegOpenKeyEx( hKey, subKey, 0, samDesired, &Result);
|
39 |
|
40 | if ( ret != ERROR_SUCCESS )
|
41 | {
|
42 | cout << "ERROR - Regestry konnte nicht geoeffnet werden" << endl;
|
43 | cout << ret << endl;
|
44 | return false;
|
45 | }
|
46 |
|
47 | cout << "Registry erfolgreich geoeffnet!" << endl;
|
48 |
|
49 |
|
50 |
|
51 | do
|
52 | {
|
53 | ret = RegEnumValue( hKey,
|
54 | dwIndex++,
|
55 | lpValueName,
|
56 | &lpcValueName,
|
57 | NULL,
|
58 | NULL,
|
59 | lpData,
|
60 | &lpcbData);
|
61 | for ( int i = 0 ; i < lpcValueName ; i++ )
|
62 | {
|
63 | cout << lpData[i];// << endl;
|
64 | }
|
65 |
|
66 | cout << endl << endl;
|
67 | /* if (ret != ERROR_NO_MORE_ITEMS)
|
68 | {
|
69 | //m_ComPorts.AddString(strData);
|
70 | //m_BTN_COMOpenClose.EnableWindow(TRUE);
|
71 | cout << chData << endl;
|
72 | }//if (res != ERROR_NO_MORE_ITEMS)
|
73 | */
|
74 | }
|
75 | while (ret != ERROR_NO_MORE_ITEMS);
|
76 |
|
77 | if ( RegCloseKey ( hKey ) != ERROR_SUCCESS )
|
78 | cout << "ERROR - Regestry konnte nicht geschlossen werden!" << endl;
|
79 | else
|
80 | cout << "Regestry erfolgreich geschlossen" << endl;
|
81 |
|
82 | return true;
|
83 |
|
84 |
|
85 | }
|