MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / WinMain

Function WinMain

src/Notepad2.c:319–435  ·  view source on GitHub ↗

============================================================================= WinMain()

Source from the content-addressed store, hash-verified

317//
318//
319int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )
320{
321 MSG msg;
322 HWND hwnd;
323 HACCEL hAccMain;
324 HACCEL hAccFindReplace;
325 INITCOMMONCONTROLSEX icex;
326 //HMODULE hSciLexer;
327 WCHAR wchWorkingDirectory[MAX_PATH];
328 // Set global variable g_hInstance
329 g_hInstance = hInstance;
330 // Set the Windows version global variable
331 g_uWinVer = LOWORD ( GetVersion() );
332 g_uWinVer = MAKEWORD ( HIBYTE ( g_uWinVer ), LOBYTE ( g_uWinVer ) );
333 // Don't keep working directory locked
334 GetCurrentDirectory ( COUNTOF ( g_wchWorkingDirectory ), g_wchWorkingDirectory );
335 GetModuleFileName ( NULL, wchWorkingDirectory, COUNTOF ( wchWorkingDirectory ) );
336 PathRemoveFileSpec ( wchWorkingDirectory );
337 SetCurrentDirectory ( wchWorkingDirectory );
338 SetErrorMode ( SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX );
339 // check if running at least on Windows 2000
340 if ( !Is2k() ) {
341 LPVOID lpMsgBuf;
342 FormatMessage (
343 FORMAT_MESSAGE_ALLOCATE_BUFFER |
344 FORMAT_MESSAGE_FROM_SYSTEM |
345 FORMAT_MESSAGE_IGNORE_INSERTS,
346 NULL,
347 ERROR_OLD_WIN_VERSION,
348 MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
349 ( LPWSTR ) &lpMsgBuf,
350 0,
351 NULL );
352 MessageBox ( NULL, ( LPCWSTR ) lpMsgBuf, WC_NOTEPAD2, MB_OK | MB_ICONEXCLAMATION );
353 LocalFree ( lpMsgBuf );
354 return ( 0 );
355 }
356 // Check if running with elevated privileges
357 fIsElevated = IsElevated();
358 // Default Encodings (may already be used for command line parsing)
359 Encoding_InitDefaults();
360 // Command Line, Ini File and Flags
361 ParseCommandLine();
362 FindIniFile();
363 TestIniFile();
364 CreateIniFile();
365 LoadFlags();
366 // set AppUserModelID
367 PrivateSetCurrentProcessExplicitAppUserModelID ( g_wchAppUserModelID );
368 // Command Line Help Dialog
369 if ( flagDisplayHelp ) {
370 DisplayCmdLineHelp();
371 return ( 0 );
372 }
373 // Adapt window class name
374 if ( fIsElevated ) {
375 StrCat ( wchWndClass, L"U" );
376 }

Callers

nothing calls this directly

Calls 15

IsElevatedFunction · 0.85
Encoding_InitDefaultsFunction · 0.85
ParseCommandLineFunction · 0.85
FindIniFileFunction · 0.85
TestIniFileFunction · 0.85
CreateIniFileFunction · 0.85
LoadFlagsFunction · 0.85
DisplayCmdLineHelpFunction · 0.85
RelaunchElevatedFunction · 0.85
RelaunchMultiInstFunction · 0.85
ActivatePrevInstFunction · 0.85

Tested by

no test coverage detected