MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / Main

Function Main

DebugView++/DebugView++.cpp:85–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85int Main(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPWSTR /*lpstrCmdLine*/, int cmdShow)
86{
87 Win32::SetPrivilege(SE_DEBUG_NAME, true);
88 Win32::SetPrivilege(SE_CREATE_GLOBAL_NAME, true);
89
90 Win32::ComInitialization com(Win32::ComInitialization::ApartmentThreaded);
91
92 // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
93 ::DefWindowProc(nullptr, 0, 0, 0L);
94
95 AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
96
97#ifdef CONSOLE_DEBUG
98 FILE* standardOut;
99 AllocConsole();
100 freopen_s(&standardOut, "CONOUT$", "wb", stdout);
101 auto fileGuard = make_guard([standardOut] { fclose(standardOut); });
102 std::cout.clear();
103#endif
104
105 CAppModuleInitialization moduleInit(_Module, hInstance);
106
107 HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
108 HANDLE hFile = nullptr, hPipe = nullptr;
109 switch (GetFileType(hStdIn))
110 {
111 case FILE_TYPE_DISK: hFile = hStdIn; break;
112 case FILE_TYPE_PIPE: hPipe = hStdIn; break;
113 }
114
115 if (hPipe && IsDBWinViewerActive())
116 return ForwardMessagesFromPipe(hPipe);
117
118 CMainFrame wndMain;
119 MessageLoop theLoop(_Module);
120
121 auto args = Win32::GetCommandLineArguments();
122 std::wstring fileName;
123
124 for (size_t i = 1; i < args.size(); ++i)
125 {
126 if (boost::iequals(args[i], L"/min"))
127 {
128 cmdShow = SW_MINIMIZE;
129 }
130 else if (boost::iequals(args[i], L"/log"))
131 {
132 //wndMain.SetLogging(); // todo: implement: this feature is not usuable now.
133 }
134 else if (args[i][0] != '/')
135 {
136 if (!fileName.empty())
137 throw std::runtime_error("multiple filenames specified on commandline");
138 fileName = args[i];
139 }
140 }
141
142 if (wndMain.CreateEx() == nullptr)

Callers 1

wWinMainFunction · 0.70

Calls 11

SetPrivilegeFunction · 0.85
make_guardFunction · 0.85
IsDBWinViewerActiveFunction · 0.85
ForwardMessagesFromPipeFunction · 0.85
GetCommandLineArgumentsFunction · 0.85
ThrowLastErrorFunction · 0.85
LoadConfigurationMethod · 0.80
LoadMethod · 0.80
CapturePipeMethod · 0.80
sizeMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected