You need to write an analogue of the regedit utility to work with the Windows registry for coursework in c ++, and you can on c #. I would like to clarify how difficult this task is? What libraries can I use for this? What components can be used to create such a graphical interface (directory tree, etc.)?

regedit

Closed due to the fact that the issue is too general for participants aleksandr barakin , AK ♦ , 0xdb , PashaPash ♦ 30 Sep '18 at 22:13 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Comments are not intended for extended discussion; conversation moved to chat . - Yuriy SPb ♦

1 answer 1

This is a Windows program in the simplest variation. In the main window - a vertical splitter, in the left pane a tree (tree control), in the right pane a list (list control). Graphic design is easily executed even on pure WinAPI, with any framework without any problems at all. Perhaps the easiest is Visual C ++ and MFC - in the MFC project templates there is an 'Explorer' that creates this application completely, all that remains is to add specific content (that is, work with the registry). To work with the registry, you can use the CRegKey class.

ADDITION

Above there was a long dispute over whether to read the registry asynchronously for later display in treectrl and listctrl. I consider such optimization a complete stupidity, and in order not to be unfounded, I decided to write a small test that reads the main branches and reports the time spent. The original version with GetTickCount returned all zeros, so I had to redo it with a high resolution timer.

static double frequency; void EnumReg(LPCTSTR szHiveName, HKEY hHive) { LARGE_INTEGER tm0; if (!::QueryPerformanceCounter(&tm0)) throw win_error(); TCHAR szName[MAX_PATH]; DWORD uNameLen; DWORD nKeys = 0; LONG lr; for (;;) { uNameLen = MAX_PATH; lr = ::RegEnumKeyEx(hHive, nKeys++, szName, &uNameLen, NULL, NULL, NULL, NULL); if (lr == ERROR_NO_MORE_ITEMS) break; if (lr != ERROR_SUCCESS) throw win_error(lr); } LARGE_INTEGER elaps; if (!::QueryPerformanceCounter(&elaps)) throw win_error(); elaps.QuadPart -= tm0.QuadPart; double elapsed = (double)elaps.QuadPart; elapsed *= 1.0e3; // We need milliseconds elapsed /= frequency; _tprintf(_TEXT("%s:\t%u subkeys, elapsed time %7.3fms\n"), szHiveName, nKeys, elapsed); } void main() { try { LARGE_INTEGER freq; if (!::QueryPerformanceFrequency(&freq)) throw win_error(); frequency = (double)freq.QuadPart; EnumReg(_TEXT("HKEY_LOCAL_MACHINE"), HKEY_LOCAL_MACHINE); EnumReg(_TEXT("HKEY_CURRENT_USER"), HKEY_CURRENT_USER); EnumReg(_TEXT("HKEY_CLASSES_ROOT"), HKEY_CLASSES_ROOT); } catch (generic_error &se) { printf("\n\n"); printf(se.Message()); } TCHAR pat[120]; printf("\nPress any key..."); _getts(pat); } 

The result is the following:

enter image description here

From this it is obvious that the time of filling and updating the control will be at least an order of magnitude longer than the time of reading the registry. This is speaking of a uniquely huge HKCR branch. For any other key, the read time will be microseconds, so any multi-threaded optimizations will be inappropriate here.

  • Are you seriously considering the possibility of drawing a complex UI on a bare WinAPI? - VladD
  • one
    @VladD And where is the "complex UI"? Stock menu, tree view, list view and status panel. Actually, for the purposes of training, these controls could even be implemented independently. - VTT
  • @VTT: For training purposes, perhaps. But then it is worth doing the right thing, and supporting resizing the window. Many programs written in primitive frameworks that do not contain a layout manager do not support this. - VladD
  • @VladD, and you think that WinAPI programs do not support window resizing? Yeah, the statements ... - freim
  • one
    If the author doesn’t understand anything at all, then, in fact, it doesn’t matter what he writes on - the mix of noodles will turn out anyway. Because the answer is highly dependent on the requirements. For wpf, for example, you need to be bothered with patterns, and for winforms or mfc, as far as I understand the task, you can simply add controls and logic to events - tym32167