ReactOS 0.4.16-dev-92-g0c2cdca
main.c File Reference
#include "progman.h"
#include <shellapi.h>
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define WC_MDICLIENTA   "MDICLIENT"
 
#define WC_MDICLIENTW   L"MDICLIENT"
 
#define WC_MDICLIENT   WC_MDICLIENTA
 
#define BUFFER_SIZE   1024
 

Functions

static VOID MAIN_LoadGroups (VOID)
 
static VOID MAIN_MenuCommand (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
static ATOM MAIN_RegisterMainWinClass (VOID)
 
static VOID MAIN_CreateMainWindow (VOID)
 
static VOID MAIN_CreateMDIWindow (VOID)
 
static VOID MAIN_AutoStart (VOID)
 
PVOID Alloc (IN DWORD dwFlags, IN SIZE_T dwBytes)
 
BOOL Free (IN PVOID lpMem)
 
PVOID ReAlloc (IN DWORD dwFlags, IN PVOID lpMem, IN SIZE_T dwBytes)
 
PVOID AppendToBuffer (IN PVOID pBuffer, IN PSIZE_T pdwBufferSize, IN PVOID pData, IN SIZE_T dwDataSize)
 
VOID PrintStringV (IN LPCWSTR szStr, IN va_list args)
 
VOID PrintString (IN LPCWSTR szStr,...)
 
VOID PrintResourceString (IN UINT uID,...)
 
VOID PrintWin32Error (IN LPWSTR Message, IN DWORD ErrorCode)
 
int ShowLastWin32Error (VOID)
 
static BOOL GetUserAndDomainName (OUT LPWSTR *UserName, OUT LPWSTR *DomainName)
 
static VOID MAIN_SetMainWindowTitle (VOID)
 
static BOOL MAIN_LoadSettings (VOID)
 
static BOOL MAIN_SaveSettings (VOID)
 
INT WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
 
static LRESULT CALLBACK MAIN_MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT MAIN_MessageBoxIDS (UINT ids_text, UINT ids_title, WORD type)
 
INT MAIN_MessageBoxIDS_s (UINT ids_text, LPCWSTR str, UINT ids_title, WORD type)
 
VOID MAIN_ReplaceString (LPWSTR *string, LPWSTR replace)
 

Variables

GLOBALS Globals
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   1024

Definition at line 55 of file main.c.

◆ WC_MDICLIENT

#define WC_MDICLIENT   WC_MDICLIENTA

Definition at line 42 of file main.c.

◆ WC_MDICLIENTA

#define WC_MDICLIENTA   "MDICLIENT"

Definition at line 36 of file main.c.

◆ WC_MDICLIENTW

#define WC_MDICLIENTW   L"MDICLIENT"

Definition at line 37 of file main.c.

Function Documentation

◆ Alloc()

PVOID Alloc ( IN DWORD  dwFlags,
IN SIZE_T  dwBytes 
)

Definition at line 63 of file main.c.

65{
66 return HeapAlloc(GetProcessHeap(), dwFlags, dwBytes);
67}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by AppendToBuffer(), COMBOEX_Create(), COMBOEX_NotifyItem(), CompareFileName(), create_taskdialog_template(), CreatePropertySheetPageA(), CreatePropertySheetPageW(), DATETIME_Create(), DATETIME_SetFormatA(), DPA_CreateEx(), DrawStatusTextA(), DSA_Create(), Ext2MapExtent(), GetUserAndDomainName(), GROUP_AddGroup(), heap_strdupAtoW(), heap_strdupW(), InitFunctionPtrs(), FxLookasideList::InitObjectAlloc(), FxPagedLookasideListFromPool::InitPagedAlloc(), LISTVIEW_EndEditLabelT(), LISTVIEW_InsertColumnT(), LISTVIEW_InsertItemT(), LISTVIEW_NCCreate(), load_string(), MAIN_LoadSettings(), MAIN_ReplaceString(), MAIN_SetMainWindowTitle(), MakeDragList(), NATIVEFONT_Create(), notify_dispinfoT(), PROGRAM_AddProgram(), PropertySheetA(), PropertySheetW(), PROPSHEET_CollectSheetInfoA(), PROPSHEET_CreateDialog(), PROPSHEET_CreatePage(), PROPSHEET_DialogProc(), PROPSHEET_InsertPage(), PROPSHEET_RemovePage(), PROPSHEET_SetTitleW(), ranges_add(), ranges_clone(), ranges_create(), ranges_del(), REBAR_InsertBandT(), REBAR_NCCreate(), set_sub_item(), SetWindowSubclass(), STATUSBAR_SetParts(), STATUSBAR_SetTextT(), STATUSBAR_WMCreate(), STATUSBAR_WMSetText(), SYSLINK_AppendDocItem(), SYSLINK_ParseText(), SYSLINK_SetItem(), SysLinkWindowProc(), TAB_Create(), TAB_InsertItemT(), taskdialog_add_buttons(), taskdialog_add_command_links(), taskdialog_add_radio_buttons(), taskdialog_get_label_size(), taskdialog_gettext(), taskdialog_layout(), textdupTtoW(), TOOLBAR_Cust_AddButton(), TOOLBAR_CustomizeDialogProc(), TOOLBAR_DeleteButton(), TOOLBAR_InsertImageList(), TOOLBAR_NCCreate(), TOOLBAR_Restore(), TOOLBAR_Save(), TOOLBAR_SaveRestoreA(), TOOLBAR_TTGetDispInfo(), TOOLTIPS_AddToolT(), TOOLTIPS_Create(), TOOLTIPS_DelToolT(), TOOLTIPS_SetTitleT(), TOOLTIPS_SetToolText(), TRACKBAR_Create(), UDFBuildLongAllocDescs(), UDFBuildShortAllocDescs(), and ValidateEditContents().

◆ AppendToBuffer()

PVOID AppendToBuffer ( IN PVOID  pBuffer,
IN PSIZE_T  pdwBufferSize,
IN PVOID  pData,
IN SIZE_T  dwDataSize 
)

Definition at line 84 of file main.c.

88{
89 PVOID pTmp;
90 SIZE_T dwBufferSize;
91
92 dwBufferSize = dwDataSize + *pdwBufferSize;
93
94 if (pBuffer)
95 pTmp = ReAlloc(0, pBuffer, dwBufferSize);
96 else
97 pTmp = Alloc(0, dwBufferSize);
98
99 if (!pTmp)
100 return NULL;
101
102 memcpy((PVOID)((ULONG_PTR)pTmp + *pdwBufferSize), pData, dwDataSize);
103 *pdwBufferSize = dwBufferSize;
104
105 return pTmp;
106}
PVOID ReAlloc(IN DWORD dwFlags, IN PVOID lpMem, IN SIZE_T dwBytes)
Definition: main.c:76
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: main.c:63
#define NULL
Definition: types.h:112
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PVOID pBuffer
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ Free()

BOOL Free ( IN PVOID  lpMem)

Definition at line 70 of file main.c.

71{
72 return HeapFree(GetProcessHeap(), 0, lpMem);
73}
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ GetUserAndDomainName()

static BOOL GetUserAndDomainName ( OUT LPWSTR UserName,
OUT LPWSTR DomainName 
)
static

Definition at line 183 of file main.c.

185{
186 BOOL bRet = TRUE;
187 HANDLE hToken;
188 DWORD cbTokenBuffer = 0;
189 PTOKEN_USER pUserToken;
190
191 LPWSTR lpUserName = NULL;
192 LPWSTR lpDomainName = NULL;
193 DWORD cbUserName = 0;
194 DWORD cbDomainName = 0;
195
196 SID_NAME_USE SidNameUse;
197
198 /* Get the process token */
200 return FALSE;
201
202 /* Retrieve token's information */
203 if (!GetTokenInformation(hToken, TokenUser, NULL, 0, &cbTokenBuffer))
204 {
206 {
207 CloseHandle(hToken);
208 return FALSE;
209 }
210 }
211
212 pUserToken = Alloc(HEAP_ZERO_MEMORY, cbTokenBuffer);
213 if (!pUserToken)
214 {
215 CloseHandle(hToken);
216 return FALSE;
217 }
218
219 if (!GetTokenInformation(hToken, TokenUser, pUserToken, cbTokenBuffer, &cbTokenBuffer))
220 {
221 Free(pUserToken);
222 CloseHandle(hToken);
223 return FALSE;
224 }
225
226 CloseHandle(hToken);
227
228 /* Retrieve the domain and user name */
230 pUserToken->User.Sid,
231 NULL,
232 &cbUserName,
233 NULL,
234 &cbDomainName,
235 &SidNameUse))
236 {
238 {
239 bRet = FALSE;
240 goto done;
241 }
242 }
243
244 lpUserName = Alloc(HEAP_ZERO_MEMORY, cbUserName * sizeof(WCHAR));
245 if (lpUserName == NULL)
246 {
247 bRet = FALSE;
248 goto done;
249 }
250
251 lpDomainName = Alloc(HEAP_ZERO_MEMORY, cbDomainName * sizeof(WCHAR));
252 if (lpDomainName == NULL)
253 {
254 bRet = FALSE;
255 goto done;
256 }
257
259 pUserToken->User.Sid,
260 lpUserName,
261 &cbUserName,
262 lpDomainName,
263 &cbDomainName,
264 &SidNameUse))
265 {
266 bRet = FALSE;
267 goto done;
268 }
269
270 *UserName = lpUserName;
271 *DomainName = lpDomainName;
272
273done:
274 if (bRet == FALSE)
275 {
276 if (lpUserName != NULL)
277 Free(lpUserName);
278
279 if (lpDomainName != NULL)
280 Free(lpDomainName);
281 }
282
283 Free(pUserToken);
284
285 return bRet;
286}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupAccountSidW(LPCWSTR pSystemName, PSID pSid, LPWSTR pAccountName, LPDWORD pdwAccountName, LPWSTR pDomainName, LPDWORD pdwDomainName, PSID_NAME_USE peUse)
Definition: misc.c:537
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
enum _SID_NAME_USE SID_NAME_USE
SID_AND_ATTRIBUTES User
Definition: setypes.h:1010
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenUser
Definition: setypes.h:966
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by MAIN_SetMainWindowTitle().

◆ MAIN_AutoStart()

static VOID MAIN_AutoStart ( VOID  )
static

Definition at line 728 of file main.c.

729{
730 LONG lRet;
732 DWORD dwType;
733
734 PROGGROUP* hGroup;
735 PROGRAM* hProgram;
736
738
739 dwSize = sizeof(buffer);
740 lRet = RegQueryValueExW(Globals.hKeyPMSettings, L"Startup", NULL, &dwType, (LPBYTE)buffer, &dwSize);
741 if (lRet != ERROR_SUCCESS || dwType != REG_SZ)
742 return;
743
744 for (hGroup = Globals.hGroups; hGroup; hGroup = hGroup->hNext)
745 {
746 if (_wcsicmp(buffer, hGroup->hName) == 0)
747 {
748 for (hProgram = hGroup->hPrograms; hProgram; hProgram = hProgram->hNext)
749 PROGRAM_ExecuteProgram(hProgram);
750 }
751 }
752}
OSK_GLOBALS Globals
Definition: main.c:16
#define BUFFER_SIZE
Definition: main.c:55
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
GLuint buffer
Definition: glext.h:5915
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
VOID PROGRAM_ExecuteProgram(PROGRAM *hProgram)
Definition: program.c:274
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
PROGRAM * hPrograms
Definition: progman.h:139
LPWSTR hName
Definition: progman.h:138
PROGGROUP * hNext
Definition: progman.h:115
PROGRAM * hNext
Definition: progman.h:85
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by wWinMain().

◆ MAIN_CreateMainWindow()

static VOID MAIN_CreateMainWindow ( VOID  )
static

Definition at line 1077 of file main.c.

1078{
1079 INT left, top, right, bottom;
1080 INT width, height;
1081 INT nCmdShow;
1082 WCHAR buffer[100];
1083
1084 LONG lRet;
1085 DWORD dwSize;
1086 DWORD dwType;
1087
1088 Globals.hMDIWnd = NULL;
1089 Globals.hMainMenu = NULL;
1090
1091 /* Get the geometry of the main window */
1092 dwSize = sizeof(buffer);
1093 lRet = RegQueryValueExW(Globals.hKeyPMSettings, L"Window", NULL, &dwType, (LPBYTE)buffer, &dwSize);
1094 if (lRet != ERROR_SUCCESS || dwType != REG_SZ)
1095 buffer[0] = '\0';
1096
1097 if (swscanf(buffer, L"%d %d %d %d %d", &left, &top, &right, &bottom, &nCmdShow) == 5)
1098 {
1099 width = right - left;
1100 height = bottom - top;
1101 }
1102 else
1103 {
1105 nCmdShow = SW_SHOWNORMAL;
1106 }
1107
1108 /* Create the main window */
1111 szTitle,
1112 WS_OVERLAPPEDWINDOW, // /* | WS_CLIPSIBLINGS | WS_CLIPCHILDREN */
1113 left, top, width, height,
1114 NULL, NULL,
1116 NULL);
1117
1119 ShowWindow(Globals.hMainWnd, nCmdShow);
1121}
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:30
static VOID MAIN_SetMainWindowTitle(VOID)
Definition: main.c:295
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLint GLint bottom
Definition: glext.h:7726
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define STRING_MAIN_WIN_CLASS_NAME
Definition: progman.h:251
HINSTANCE hInstance
Definition: precomp.h:52
HWND hMainWnd
Definition: precomp.h:53
int32_t INT
Definition: typedefs.h:58
#define SW_SHOWNORMAL
Definition: winuser.h:773
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4319
#define CW_USEDEFAULT
Definition: winuser.h:225

Referenced by wWinMain().

◆ MAIN_CreateMDIWindow()

static VOID MAIN_CreateMDIWindow ( VOID  )
static

Definition at line 1128 of file main.c.

1129{
1131 RECT rect;
1132
1133 /* Get the geometry of the MDI window */
1135
1136 ccs.hWindowMenu = Globals.hWindowsMenu;
1138
1139 /* Create MDI Window */
1140 Globals.hMDIWnd =
1142 rect.left, rect.top,
1143 rect.right - rect.left, rect.bottom - rect.top,
1144 Globals.hMainWnd, 0,
1145 Globals.hInstance, &ccs);
1146
1147 /* Reset the background of the MDI client window (default: COLOR_APPWORKSPACE + 1) */
1149
1150 ShowWindow(Globals.hMDIWnd, SW_SHOW);
1151 UpdateWindow(Globals.hMDIWnd);
1152}
#define WC_MDICLIENT
Definition: main.c:42
#define PM_FIRST_CHILD
Definition: resource.h:94
#define WS_CHILD
Definition: pedump.c:617
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_CLIPCHILDREN
Definition: pedump.c:619
& rect
Definition: startmenu.cpp:1413
#define SetClassLongPtrW
Definition: winuser.h:5277
#define COLOR_WINDOW
Definition: winuser.h:921
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SW_SHOW
Definition: winuser.h:778
#define GCLP_HBRBACKGROUND
Definition: winuser.h:672

Referenced by wWinMain().

◆ MAIN_LoadGroups()

static VOID MAIN_LoadGroups ( VOID  )
static

Definition at line 719 of file main.c.

720{
721}

Referenced by wWinMain().

◆ MAIN_LoadSettings()

static BOOL MAIN_LoadSettings ( VOID  )
static

Definition at line 332 of file main.c.

333{
334 LPWSTR lpszTmp;
335 LPWSTR lpszSection;
336 LONG lRet;
337 WCHAR dummy[2];
338 LPWSTR lpszKeyValue;
339 const LPCWSTR lpszIniFile = L"progman.ini";
340 WCHAR szWinDir[MAX_PATH];
341 LPWSTR lpszKey;
342 DWORD Value;
343 HKEY hKey;
344 BOOL bIsIniMigrated;
346 LPWSTR lpszSections;
347 LPWSTR lpszData;
348 DWORD dwRet;
349 DWORD dwType;
350 LPWSTR lpszValue;
351
352 bIsIniMigrated = FALSE;
353 lpszSections = NULL;
354 lpszData = NULL;
355
356 /* Try to create/open the Program Manager user key */
358 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Program Manager",
359 0,
360 NULL,
363 NULL,
364 &Globals.hKeyProgMan,
366 {
367 return FALSE;
368 }
369
370 /*
371 * TODO: Add the explanation for the migration...
372 */
373 dwSize = sizeof(Value);
374 lRet = RegQueryValueExW(Globals.hKeyProgMan, L"IniMigrated", NULL, &dwType, (LPBYTE)&Value, &dwSize);
375 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
376 Value = 0;
377 bIsIniMigrated = !!Value;
378
379 if (bIsIniMigrated)
380 {
381 /* The migration was already done, just load the settings */
382 goto LoadSettings;
383 }
384
385 /* Perform the migration */
386
387 bIsIniMigrated = TRUE;
389 SetLastError(0);
390 GetPrivateProfileSectionW(L"Settings", dummy, dwSize, lpszIniFile);
392 goto MigrationDone;
393
394 SetLastError(0);
395 GetPrivateProfileSectionW(L"Groups", dummy, dwSize, lpszIniFile);
397 goto MigrationDone;
398
399 GetWindowsDirectoryW(szWinDir, ARRAYSIZE(szWinDir));
400 // NOTE: GCC complains we cannot use the "\u2022" (UNICODE Code Point) notation for specifying the bullet character,
401 // because it's only available in C++ or in C99. On the contrary MSVC is fine with it.
402 // Instead we use a hex specification for the character: "\x2022".
403 // Note also that the character "\x07" gives also a bullet, but a larger one.
405 L"The Program Manager has detected the presence of a legacy settings file PROGMAN.INI in the directory '%s' "
406 L"and is going to migrate its contents into the current-user Program Manager settings registry key:\n"
407 L"HKCU\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Program Manager"
408 L"\n\n"
409 L"\x2022 The migration operation will potentially overwrite all the existing current-user Program Manager settings in the registry by those stored in the PROGMAN.INI file.\n"
410 L"\n"
411 L"\x2022 The migration is done once, so that, at the next launch of the Program Manager, the new migrated settings are directly used.\n"
412 L"\n"
413 L"\x2022 It is possible to trigger later the migration by manually deleting the registry value \"IniMigrated\" under the current-user Program Manager settings registry key (specified above).\n"
414 L"\n"
415 L"Would you like to migrate its contents into the registry?",
416 szWinDir);
417
419 {
420 lpszSections = Alloc(0, dwSize * sizeof(WCHAR));
421 dwRet = GetPrivateProfileSectionNamesW(lpszSections, dwSize, lpszIniFile);
422 if (dwRet < dwSize - 2)
423 break;
424 Free(lpszSections);
425 }
426 lpszSection = lpszSections;
427 while (*lpszSection)
428 {
429 lRet = RegCreateKeyExW(Globals.hKeyProgMan,
430 lpszSection,
431 0,
432 NULL,
434 KEY_WRITE,
435 NULL,
436 &hKey,
437 NULL);
438 if (lRet == ERROR_SUCCESS)
439 {
441 {
442 lpszData = Alloc(0, dwSize * sizeof(WCHAR));
443 dwRet = GetPrivateProfileSectionW(lpszSection, lpszData, dwSize, lpszIniFile);
444 if (dwRet < dwSize - 2)
445 break;
446 Free(lpszData);
447 }
448 lpszKeyValue = lpszData;
449 while (*lpszKeyValue)
450 {
451 lpszKey = lpszKeyValue;
452 lpszValue = wcschr(lpszKeyValue, L'=');
453 lpszKeyValue += (wcslen(lpszKeyValue) + 1);
454 if (lpszValue)
455 {
456 *lpszValue = '\0';
457 ++lpszValue;
458 Value = wcstoul(lpszValue, &lpszTmp, 0);
459 if (lpszTmp - lpszValue >= wcslen(lpszValue))
460 {
461 lpszValue = (LPWSTR)&Value;
462 dwSize = sizeof(Value);
463 dwType = REG_DWORD;
464 }
465 else
466 {
467 dwSize = wcslen(lpszValue) * sizeof(WCHAR);
468 dwType = REG_SZ;
469 }
470 }
471 else
472 {
473 dwSize = 0;
474 dwType = REG_DWORD;
475 }
476 lRet = RegSetValueExW(hKey, lpszKey, 0, dwType, (LPBYTE)lpszValue, dwSize);
477 }
478 Free(lpszData);
480 lpszSection += (wcslen(lpszSection) + 1);
481 }
482 }
483 Free(lpszSections);
484
485MigrationDone:
486 Value = TRUE;
487 RegSetValueExW(Globals.hKeyProgMan, L"IniMigrated", 0, REG_DWORD, (LPBYTE)&Value, sizeof(Value));
488
489
491 /* Create the necessary registry keys for the Program Manager and load its settings from the registry */
492
493 lRet = RegCreateKeyExW(Globals.hKeyProgMan,
494 L"Settings",
495 0,
496 NULL,
499 NULL,
500 &Globals.hKeyPMSettings,
501 NULL);
502
503 lRet = RegCreateKeyExW(Globals.hKeyProgMan,
504 L"Common Groups",
505 0,
506 NULL,
509 NULL,
510 &Globals.hKeyPMCommonGroups,
511 NULL);
512
513 lRet = RegCreateKeyExW(Globals.hKeyProgMan,
514 L"Groups",
515 0,
516 NULL,
519 NULL,
520 &Globals.hKeyPMAnsiGroups,
521 NULL);
522
523 lRet = RegCreateKeyExW(Globals.hKeyProgMan,
524 L"UNICODE Groups",
525 0,
526 NULL,
529 NULL,
530 &Globals.hKeyPMUnicodeGroups,
531 NULL);
532
534 L"Program Groups",
535 0,
536 NULL,
539 NULL,
540 &Globals.hKeyAnsiGroups,
541 NULL);
542
544 L"UNICODE Program Groups",
545 0,
546 NULL,
549 NULL,
550 &Globals.hKeyUnicodeGroups,
551 NULL);
552
554 L"SOFTWARE\\Program Groups",
555 0,
556 NULL,
559 NULL,
560 &Globals.hKeyCommonGroups,
561 NULL);
562
563 dwSize = sizeof(Globals.bAutoArrange);
564 RegQueryValueExW(Globals.hKeyPMSettings, L"AutoArrange", NULL, &dwType, (LPBYTE)&Globals.bAutoArrange, &dwSize);
565
566 dwSize = sizeof(Globals.bMinOnRun);
567 RegQueryValueExW(Globals.hKeyPMSettings, L"MinOnRun", NULL, &dwType, (LPBYTE)&Globals.bMinOnRun, &dwSize);
568
569 dwSize = sizeof(Globals.bSaveSettings);
570 RegQueryValueExW(Globals.hKeyPMSettings, L"SaveSettings", NULL, &dwType, (LPBYTE)&Globals.bSaveSettings, &dwSize);
571
572 return TRUE;
573}
void LoadSettings(void)
Definition: settings.c:53
VOID PrintString(IN LPCWSTR szStr,...)
Definition: main.c:124
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define wcschr
Definition: compat.h:17
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
DWORD WINAPI GetPrivateProfileSectionNamesW(LPWSTR buffer, DWORD size, LPCWSTR filename)
Definition: profile.c:1641
INT WINAPI GetPrivateProfileSectionW(LPCWSTR section, LPWSTR buffer, DWORD len, LPCWSTR filename)
Definition: profile.c:1351
FxAutoRegKey hKey
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_DWORD
Definition: sdbapi.c:596
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by wWinMain().

◆ MAIN_MainWndProc()

static LRESULT CALLBACK MAIN_MainWndProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 759 of file main.c.

760{
761 switch (uMsg)
762 {
763 case WM_INITMENU:
764 {
765 PROGGROUP* hActiveGroup = GROUP_ActiveGroup();
766 if (hActiveGroup)
767 {
768 if (PROGRAM_ActiveProgram(hActiveGroup))
769 {
775 }
776 else
777 {
778 if (!hActiveGroup->hWnd || IsIconic(hActiveGroup->hWnd))
780 else
782
787 }
788 }
789 else
790 {
796 }
797
799 MF_BYCOMMAND | (Globals.bAutoArrange ? MF_CHECKED : MF_UNCHECKED));
801 MF_BYCOMMAND | (Globals.bMinOnRun ? MF_CHECKED : MF_UNCHECKED));
803 MF_BYCOMMAND | (Globals.bSaveSettings ? MF_CHECKED : MF_UNCHECKED));
804 break;
805 }
806
807 case WM_DESTROY:
808 if (Globals.bSaveSettings)
811 break;
812
813 case WM_COMMAND:
816 break;
817 }
818
819 return DefFrameProcW(hWnd, Globals.hMDIWnd, uMsg, wParam, lParam);
820}
HWND hWnd
Definition: settings.c:17
PROGGROUP * GROUP_ActiveGroup(VOID)
Definition: group.c:671
static VOID MAIN_MenuCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: main.c:828
static BOOL MAIN_SaveSettings(VOID)
Definition: main.c:577
#define PM_MIN_ON_RUN
Definition: resource.h:87
#define PM_SAVE_SETTINGS
Definition: resource.h:88
#define PM_AUTO_ARRANGE
Definition: resource.h:86
#define PM_COPY
Definition: resource.h:80
#define PM_OPEN
Definition: resource.h:78
#define PM_DELETE
Definition: resource.h:81
#define PM_ATTRIBUTES
Definition: resource.h:82
#define PM_MOVE
Definition: resource.h:79
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
PROGRAM * PROGRAM_ActiveProgram(PROGGROUP *hGroup)
Definition: program.c:331
HWND hWnd
Definition: progman.h:116
LRESULT WINAPI DefFrameProcW(_In_ HWND, _In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MF_BYCOMMAND
Definition: winuser.h:202
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1743
#define MF_CHECKED
Definition: winuser.h:132
#define WM_INITMENU
Definition: winuser.h:1748
#define MF_UNCHECKED
Definition: winuser.h:204
BOOL WINAPI IsIconic(_In_ HWND)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_ENABLED
Definition: winuser.h:128
#define WM_DESTROY
Definition: winuser.h:1612
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129

Referenced by MAIN_RegisterMainWinClass().

◆ MAIN_MenuCommand()

static VOID MAIN_MenuCommand ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 828 of file main.c.

829{
830#if 0
831 HLOCAL hActiveGroup = GROUP_ActiveGroup();
832 HLOCAL hActiveProgram = PROGRAM_ActiveProgram(hActiveGroup);
833 HWND hActiveGroupWnd = GROUP_GroupWnd(hActiveGroup);
834
835 switch(wParam)
836 {
837 /* Menu File */
838 case PM_NEW:
839 switch (DIALOG_New((hActiveGroupWnd && !IsIconic(hActiveGroupWnd)) ?
841 {
842 case PM_NEW_PROGRAM:
843 if (hActiveGroup) PROGRAM_NewProgram(hActiveGroup);
844 break;
845
846 case PM_NEW_GROUP:
848 break;
849 }
850 break;
851
852
853 case PM_DELETE:
854 if (hActiveProgram)
855 {
856 if (DIALOG_Delete(IDS_DELETE_PROGRAM_s, PROGRAM_ProgramName(hActiveProgram)))
857 PROGRAM_DeleteProgram(hActiveProgram, TRUE);
858 }
859 else if (hActiveGroup)
860 {
861 if (DIALOG_Delete(IDS_DELETE_GROUP_s, GROUP_GroupName(hActiveGroup)))
862 GROUP_DeleteGroup(hActiveGroup);
863 }
864 break;
865
866
867
868 case PM_SAVE_SETTINGS:
869 Globals.bSaveSettings = !Globals.bSaveSettings;
871 MF_BYCOMMAND | (Globals.bSaveSettings ?
873 WritePrivateProfileStringA("Settings", "SaveSettings",
874 Globals.bSaveSettings ? "1" : "0",
875 Globals.lpszIniFile);
876 WritePrivateProfileStringA(NULL,NULL,NULL,Globals.lpszIniFile); /* flush it */
877 break;
878
879
880 case PM_ARRANGE:
881
882 if (hActiveGroupWnd && !IsIconic(hActiveGroupWnd))
883 ArrangeIconicWindows(hActiveGroupWnd);
884 else
885 SendMessageW(Globals.hMDIWnd, WM_MDIICONARRANGE, 0, 0);
886 break;
887
888 }
889
890
891
892
893#endif
894
895 DWORD Value;
896
897 PROGGROUP* hActiveGroup;
898 PROGRAM* hActiveProgram;
899 HWND hActiveGroupWnd;
900
901 hActiveGroup = GROUP_ActiveGroup();
902 hActiveProgram = PROGRAM_ActiveProgram(hActiveGroup);
903 hActiveGroupWnd = (hActiveGroup ? hActiveGroup->hWnd : NULL);
904
905 switch (wParam)
906 {
907 /* Menu File */
908
909 case PM_NEW:
910 {
912 INT nResult;
913
914 if (!hActiveGroupWnd || IsIconic(hActiveGroupWnd))
915 Success = DIALOG_New(PM_NEW_GROUP, &nResult);
916 else
917 Success = DIALOG_New(PM_NEW_PROGRAM, &nResult);
918 if (!Success)
919 break;
920
921 if (nResult & 1)
922 {
924 BOOL bIsCommonGroup;
925
926 format = (nResult & 0xC) >> 2;
927 bIsCommonGroup = (nResult & 2) != 0;
928 GROUP_NewGroup(format, bIsCommonGroup);
929 }
930 else if (hActiveGroup)
931 {
932 PROGRAM_NewProgram(hActiveGroup);
933 }
934
935 break;
936 }
937
938 case PM_OPEN:
939 if (hActiveProgram)
940 PROGRAM_ExecuteProgram(hActiveProgram);
941 else if (hActiveGroupWnd)
942 OpenIcon(hActiveGroupWnd);
943 break;
944
945 case PM_MOVE:
946 case PM_COPY:
947 if (hActiveProgram)
948 PROGRAM_CopyMoveProgram(hActiveProgram, wParam == PM_MOVE);
949 break;
950
951 case PM_DELETE:
952 {
953 if (hActiveProgram)
954 {
955 if (DIALOG_Delete(IDS_DELETE_PROGRAM_s, hActiveProgram->hName))
956 PROGRAM_DeleteProgram(hActiveProgram, TRUE);
957 }
958 else if (hActiveGroup && DIALOG_Delete(IDS_DELETE_GROUP_s, hActiveGroup->hName))
959 {
960 GROUP_DeleteGroup(hActiveGroup);
961 }
962 break;
963 }
964
965 case PM_ATTRIBUTES:
966 if (hActiveProgram)
967 PROGRAM_ModifyProgram(hActiveProgram);
968 else if (hActiveGroup)
969 GROUP_ModifyGroup(hActiveGroup);
970 break;
971
972 case PM_EXECUTE:
974 break;
975
976 case PM_EXIT:
977 // MAIN_SaveSettings();
979 break;
980
981
982 /* Menu Options */
983
984 case PM_AUTO_ARRANGE:
985 Globals.bAutoArrange = !Globals.bAutoArrange;
987 MF_BYCOMMAND | (Globals.bAutoArrange ? MF_CHECKED : MF_UNCHECKED));
988 Value = Globals.bAutoArrange;
989 RegSetValueExW(Globals.hKeyPMSettings, L"AutoArrange", 0, REG_DWORD, (LPBYTE)&Value, sizeof(Value));
990 break;
991
992 case PM_MIN_ON_RUN:
993 Globals.bMinOnRun = !Globals.bMinOnRun;
995 MF_BYCOMMAND | (Globals.bMinOnRun ? MF_CHECKED : MF_UNCHECKED));
996 Value = Globals.bMinOnRun;
997 RegSetValueExW(Globals.hKeyPMSettings, L"MinOnRun", 0, REG_DWORD, (LPBYTE)&Value, sizeof(Value));
998 break;
999
1000 case PM_SAVE_SETTINGS:
1001 Globals.bSaveSettings = !Globals.bSaveSettings;
1003 MF_BYCOMMAND | (Globals.bSaveSettings ? MF_CHECKED : MF_UNCHECKED));
1004 Value = Globals.bSaveSettings;
1005 RegSetValueExW(Globals.hKeyPMSettings, L"SaveSettings", 0, REG_DWORD, (LPBYTE)&Value, sizeof(Value));
1006 break;
1007
1010 break;
1011
1012
1013 /* Menu Windows */
1014
1015 case PM_OVERLAP:
1016 SendMessageW(Globals.hMDIWnd, WM_MDICASCADE, 0, 0);
1017 break;
1018
1019 case PM_SIDE_BY_SIDE:
1021 break;
1022
1023 case PM_ARRANGE:
1024 if (!hActiveGroupWnd || IsIconic(hActiveGroupWnd))
1025 SendMessageW(Globals.hMDIWnd, WM_MDIICONARRANGE, 0, 0);
1026 else
1027 SendMessageA(hActiveGroup->hListView, LVM_ARRANGE, 0, 0);
1028 break;
1029
1030
1031 /* Menu Help */
1032
1033 case PM_CONTENTS:
1034 if (!WinHelpW(Globals.hMainWnd, L"progman.hlp", HELP_CONTENTS, 0))
1036 break;
1037
1038 case PM_ABOUT:
1039 ShellAboutW(hWnd, szTitle, NULL, Globals.hMainIcon);
1040 break;
1041
1042 default:
1044 break;
1045 }
1046
1047}
#define IDS_ERROR
Definition: resource.h:18
#define PM_NEW
Definition: main.h:23
BOOL DIALOG_Delete(UINT ids_text_s, LPCWSTR lpszName)
Definition: dialog.c:361
BOOL DIALOG_New(INT nDefault, PINT pnResult)
Definition: dialog.c:233
VOID DIALOG_Execute(VOID)
Definition: dialog.c:1021
VOID GROUP_ModifyGroup(PROGGROUP *hGroup)
Definition: group.c:596
VOID GROUP_DeleteGroup(PROGGROUP *hGroup)
Definition: group.c:627
VOID GROUP_NewGroup(GROUPFORMAT format, BOOL bIsCommonGroup)
Definition: group.c:392
INT MAIN_MessageBoxIDS(UINT ids_text, UINT ids_title, WORD type)
Definition: main.c:1159
#define IDS_NOT_IMPLEMENTED
Definition: resource.h:59
#define PM_EXIT
Definition: resource.h:84
#define PM_CONTENTS
Definition: resource.h:101
#define PM_OVERLAP
Definition: resource.h:91
#define PM_ARRANGE
Definition: resource.h:93
#define PM_NEW_PROGRAM
Definition: resource.h:118
#define IDS_WINHELP_ERROR
Definition: resource.h:64
#define PM_ABOUT
Definition: resource.h:102
#define PM_NEW_GROUP
Definition: resource.h:117
#define PM_SAVE_SETTINGS_NOW
Definition: resource.h:89
#define PM_SIDE_BY_SIDE
Definition: resource.h:92
#define PM_EXECUTE
Definition: resource.h:83
#define IDS_DELETE_PROGRAM_s
Definition: resource.h:56
#define IDS_DELETE_GROUP_s
Definition: resource.h:55
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
@ Success
Definition: eventcreate.c:712
VOID PROGRAM_CopyMoveProgram(PROGRAM *hProgram, BOOL bMove)
Definition: program.c:236
VOID PROGRAM_ModifyProgram(PROGRAM *hProgram)
Definition: program.c:116
VOID PROGRAM_DeleteProgram(PROGRAM *hProgram, BOOL bUpdateGrpFile)
Definition: program.c:289
enum _GROUPFORMAT GROUPFORMAT
VOID PROGRAM_NewProgram(PROGGROUP *hGroup)
Definition: program.c:80
#define LVM_ARRANGE
Definition: commctrl.h:2537
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
HWND hListView
Definition: progman.h:118
LPWSTR hName
Definition: progman.h:93
Definition: format.c:58
#define WM_MDITILE
Definition: winuser.h:1821
UINT WINAPI ArrangeIconicWindows(_In_ HWND)
#define WM_MDICASCADE
Definition: winuser.h:1822
#define HELP_CONTENTS
Definition: winuser.h:2408
BOOL WINAPI WinHelpW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_ UINT, _In_ ULONG_PTR)
BOOL WINAPI OpenIcon(_In_ HWND)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_MDIICONARRANGE
Definition: winuser.h:1823
#define MB_OK
Definition: winuser.h:793
#define MDITILE_VERTICAL
Definition: winuser.h:2192
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by MAIN_MainWndProc().

◆ MAIN_MessageBoxIDS()

INT MAIN_MessageBoxIDS ( UINT  ids_text,
UINT  ids_title,
WORD  type 
)

Definition at line 1159 of file main.c.

1160{
1163
1166
1168}
#define MAX_STRING_LEN
Definition: precomp.h:36
const WCHAR * text
Definition: package.c:1794
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static char title[]
Definition: ps.c:92
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)

Referenced by DIALOG_COPY_MOVE_DlgProc(), DIALOG_EXECUTE_DlgProc(), DIALOG_GROUP_DlgProc(), DIALOG_NEW_DlgProc(), DIALOG_PROGRAM_DlgProc(), DIALOG_SYMBOL_DlgProc(), GROUP_AddGroup(), MAIN_MenuCommand(), MAIN_ReplaceString(), and PROGRAM_AddProgram().

◆ MAIN_MessageBoxIDS_s()

INT MAIN_MessageBoxIDS_s ( UINT  ids_text,
LPCWSTR  str,
UINT  ids_title,
WORD  type 
)

Definition at line 1174 of file main.c.

1175{
1179
1182 wsprintfW(newtext, text, str);
1183
1184 return MessageBoxW(Globals.hMainWnd, newtext, title, type);
1185}
#define MAX_PATHNAME_LEN
Definition: progman.h:54
const WCHAR * str
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

Referenced by DIALOG_Delete(), GRPFILE_ReadGroupFile(), and GRPFILE_WriteGroupFile().

◆ MAIN_RegisterMainWinClass()

static ATOM MAIN_RegisterMainWinClass ( VOID  )
static

Definition at line 1054 of file main.c.

1055{
1056 WNDCLASSW wndClass;
1057
1058 wndClass.style = CS_HREDRAW | CS_VREDRAW;
1059 wndClass.lpfnWndProc = MAIN_MainWndProc;
1060 wndClass.cbClsExtra = 0;
1061 wndClass.cbWndExtra = 0;
1062 wndClass.hInstance = Globals.hInstance;
1063 wndClass.hIcon = Globals.hMainIcon;
1064 wndClass.hCursor = LoadCursorW(NULL, IDC_ARROW);
1065 wndClass.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
1066 wndClass.lpszMenuName = NULL;
1068
1069 return RegisterClassW(&wndClass);
1070}
static LRESULT CALLBACK MAIN_MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: main.c:759
LPCWSTR lpszClassName
Definition: winuser.h:3188
LPCWSTR lpszMenuName
Definition: winuser.h:3187
HBRUSH hbrBackground
Definition: winuser.h:3186
HICON hIcon
Definition: winuser.h:3184
HINSTANCE hInstance
Definition: winuser.h:3183
int cbClsExtra
Definition: winuser.h:3181
UINT style
Definition: winuser.h:3179
WNDPROC lpfnWndProc
Definition: winuser.h:3180
int cbWndExtra
Definition: winuser.h:3182
HCURSOR hCursor
Definition: winuser.h:3185
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define NULL_BRUSH
Definition: wingdi.h:901
#define CS_VREDRAW
Definition: winuser.h:658
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2149

Referenced by wWinMain().

◆ MAIN_ReplaceString()

VOID MAIN_ReplaceString ( LPWSTR string,
LPWSTR  replace 
)

Definition at line 1192 of file main.c.

1193{
1194 LPWSTR newstring;
1195
1196 newstring = Alloc(HEAP_ZERO_MEMORY, (wcslen(replace) + 1) * sizeof(WCHAR));
1197 if (newstring)
1198 {
1199 wcscpy(newstring, replace);
1200 *string = newstring;
1201 }
1202 else
1203 {
1205 }
1206}
#define IDS_OUT_OF_MEMORY
Definition: resource.h:5
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:38
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)

Referenced by GROUP_ModifyGroup(), and PROGRAM_ModifyProgram().

◆ MAIN_SaveSettings()

static BOOL MAIN_SaveSettings ( VOID  )
static

Definition at line 577 of file main.c.

578{
579 WINDOWPLACEMENT WndPl;
581 WCHAR buffer[100];
582
583 WndPl.length = sizeof(WndPl);
586 L"%d %d %d %d %d",
588 WndPl.rcNormalPosition.top,
591 WndPl.showCmd);
592
593 dwSize = wcslen(buffer) * sizeof(WCHAR);
594 RegSetValueExW(Globals.hKeyPMSettings, L"Window", 0, REG_SZ, (LPBYTE)buffer, dwSize);
595
596 return TRUE;
597}
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
RECT rcNormalPosition
Definition: winuser.h:3298
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)

Referenced by MAIN_MainWndProc(), and MAIN_MenuCommand().

◆ MAIN_SetMainWindowTitle()

static VOID MAIN_SetMainWindowTitle ( VOID  )
static

Definition at line 295 of file main.c.

296{
297 LPWSTR caption;
298 SIZE_T size;
299
300 LPWSTR lpDomainName = NULL;
301 LPWSTR lpUserName = NULL;
302
303 if (GetUserAndDomainName(&lpUserName, &lpDomainName) && lpUserName && lpDomainName)
304 {
305 size = (256 + 3 + wcslen(lpDomainName) + wcslen(lpUserName) + 1) * sizeof(WCHAR);
306 caption = Alloc(HEAP_ZERO_MEMORY, size);
307 if (caption)
308 {
309 StringCbPrintfW(caption, size, L"%s - %s\\%s", szTitle, lpDomainName, lpUserName);
311 Free(caption);
312 }
313 else
314 {
316 }
317 }
318 else
319 {
321 }
322
323 if (lpUserName) Free(lpUserName);
324 if (lpDomainName) Free(lpDomainName);
325}
static BOOL GetUserAndDomainName(OUT LPWSTR *UserName, OUT LPWSTR *DomainName)
Definition: main.c:183
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)

Referenced by MAIN_CreateMainWindow().

◆ PrintResourceString()

VOID PrintResourceString ( IN UINT  uID,
  ... 
)

Definition at line 134 of file main.c.

135{
136 WCHAR Buffer[4096];
138
139 va_start(args, uID);
142 va_end(args);
143}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
VOID PrintStringV(IN LPCWSTR szStr, IN va_list args)
Definition: main.c:114
Definition: bufpool.h:45
#define args
Definition: format.c:66
Definition: match.c:390

◆ PrintString()

VOID PrintString ( IN LPCWSTR  szStr,
  ... 
)

Definition at line 124 of file main.c.

125{
127
128 va_start(args, szStr);
129 PrintStringV(szStr, args);
130 va_end(args);
131}

Referenced by MAIN_LoadSettings(), and PrintWin32Error().

◆ PrintStringV()

VOID PrintStringV ( IN LPCWSTR  szStr,
IN va_list  args 
)

Definition at line 114 of file main.c.

116{
117 WCHAR Buffer[4096];
118
120 MessageBoxW(Globals.hMainWnd, Buffer, L"Information", MB_OK);
121}
_CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, va_list _Args)

Referenced by PrintResourceString(), and PrintString().

◆ PrintWin32Error()

VOID PrintWin32Error ( IN LPWSTR  Message,
IN DWORD  ErrorCode 
)

Definition at line 146 of file main.c.

147{
148 LPWSTR lpMsgBuf;
149
152 (LPWSTR)&lpMsgBuf, 0, NULL);
153
154 PrintString(L"%s: %s\n", Message, lpMsgBuf);
155 LocalFree(lpMsgBuf);
156}
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
static const WCHAR Message[]
Definition: register.c:74
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419

Referenced by main().

◆ ReAlloc()

◆ ShowLastWin32Error()

int ShowLastWin32Error ( VOID  hwndParent)

Definition at line 158 of file main.c.

159{
160 DWORD dwError;
161 LPWSTR lpMsgBuf = NULL;
162 WCHAR Buffer[4096];
163
164 dwError = GetLastError();
165
168 (LPWSTR)&lpMsgBuf, 0, NULL);
169 _snwprintf(Buffer, ARRAYSIZE(Buffer), L"Error %d: %s\n", dwError, lpMsgBuf);
170 LocalFree(lpMsgBuf);
171 return MessageBoxW(Globals.hMainWnd, Buffer, L"Error", MB_OK);
172}
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)

◆ wWinMain()

INT WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
INT  nCmdShow 
)

Definition at line 605 of file main.c.

606{
607 MSG msg;
609
610 /*
611 * Set our shutdown parameters: we want to shutdown the very last,
612 * but before any TaskMgr instance (which has a shutdown level of 1).
613 */
615
617 Globals.hGroups = NULL;
618 Globals.hActiveGroup = NULL;
619
620 /* Load Program Manager's settings */
622
623 /* Load the default icons */
628
629 /* Initialize the common controls */
630 icex.dwSize = sizeof(icex);
631 icex.dwICC = ICC_HOTKEY_CLASS | ICC_LISTVIEW_CLASSES; // | ICC_STANDARD_CLASSES;
633
634 /* Register the window classes */
635 if (!hPrevInstance) // FIXME: Unused on Win32!
636 {
637 if (!MAIN_RegisterMainWinClass()) goto Quit;
638 if (!GROUP_RegisterGroupWinClass()) goto Quit;
639 }
640
641 /* Set up the strings, the main window, the accelerators, the menu, and the MDI child window */
647
648 /* Load all the groups */
649 // MAIN_CreateGroups();
651
652 /* Load the Startup group: start the initial applications */
654
655 /* Message loop */
656 while (GetMessageW(&msg, NULL, 0, 0))
657 {
658 if (!TranslateMDISysAccel(Globals.hMDIWnd, &msg) &&
660 {
663 }
664 }
665
666Quit:
667
668 /* Save the settings, close the registry keys and quit */
669
670 // MAIN_SaveSettings();
671 RegCloseKey(Globals.hKeyCommonGroups);
672 RegCloseKey(Globals.hKeyUnicodeGroups);
673 RegCloseKey(Globals.hKeyAnsiGroups);
674 RegCloseKey(Globals.hKeyPMUnicodeGroups);
675 RegCloseKey(Globals.hKeyPMAnsiGroups);
676 RegCloseKey(Globals.hKeyPMCommonGroups);
677 RegCloseKey(Globals.hKeyPMSettings);
678 RegCloseKey(Globals.hKeyProgMan);
679
680 return 0;
681}
#define msg(x)
Definition: auth_time.c:54
#define IDI_APPICON
Definition: resource.h:166
ATOM GROUP_RegisterGroupWinClass(VOID)
Definition: group.c:369
static VOID MAIN_CreateMainWindow(VOID)
Definition: main.c:1077
static VOID MAIN_LoadGroups(VOID)
Definition: main.c:719
static VOID MAIN_AutoStart(VOID)
Definition: main.c:728
static ATOM MAIN_RegisterMainWinClass(VOID)
Definition: main.c:1054
static VOID MAIN_CreateMDIWindow(VOID)
Definition: main.c:1128
static BOOL MAIN_LoadSettings(VOID)
Definition: main.c:332
#define IDI_GROUP_PERSONAL_ICON
Definition: resource.h:40
#define IDI_GROUP_COMMON_ICON
Definition: resource.h:41
#define IDA_ACCEL
Definition: resource.h:47
HINSTANCE hInstance
Definition: charmap.c:19
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
BOOL WINAPI SetProcessShutdownParameters(IN DWORD dwLevel, IN DWORD dwFlags)
Definition: proc.c:949
VOID STRING_LoadStrings(VOID)
Definition: string.c:36
VOID STRING_LoadMenus(VOID)
Definition: string.c:41
#define ICC_HOTKEY_CLASS
Definition: commctrl.h:64
#define ICC_LISTVIEW_CLASSES
Definition: commctrl.h:58
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define IDI_WINLOGO
Definition: winuser.h:709
BOOL WINAPI TranslateMDISysAccel(_In_ HWND, _In_ LPMSG)
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2119

Variable Documentation

◆ Globals

GLOBALS Globals

Definition at line 45 of file main.c.