startup sound when set as default shell
rename global variables for easier identification
This commit is contained in:
Brady McDermott
2024-10-19 23:24:53 -06:00
parent 7234547e3d
commit 93ca902e1f
6 changed files with 96 additions and 91 deletions

View File

@@ -60,18 +60,18 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
// grp.pItemArray = 0; TODO: idk make sure this ain't all screwed up // grp.pItemArray = 0; TODO: idk make sure this ain't all screwed up
// Set the window title // Set the window title
LoadString(hAppInstance, IDS_DLT_GRP_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle)); LoadString(g_hAppInstance, IDS_DLT_GRP_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle));
SetWindowText(hWndDlg, szDlgTitle); SetWindowText(hWndDlg, szDlgTitle);
// Populate the icon with the default path and index. // Populate the icon with the default path and index.
GetModuleFileName(hAppInstance, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath)); GetModuleFileName(g_hAppInstance, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath));
grp.iIconIndex = IDI_PROGGRP - 1; grp.iIconIndex = IDI_PROGGRP - 1;
// Get the default hIcon so we can delete it later // Get the default hIcon so we can delete it later
hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0); hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0);
// Set the icon in the dialog // Set the icon in the dialog
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex); hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex);
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
// Set the maximum input length of the text boxes // Set the maximum input length of the text boxes
@@ -81,7 +81,7 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
EnableWindow(GetDlgItem(hWndDlg, IDD_OK), bOKEnabled); EnableWindow(GetDlgItem(hWndDlg, IDD_OK), bOKEnabled);
// Enable the common group checkbox if perms are good // Enable the common group checkbox if perms are good
EnableWindow(GetDlgItem(hWndDlg, IDD_COMMGROUP), bPermAdmin); EnableWindow(GetDlgItem(hWndDlg, IDD_COMMGROUP), g_bPermAdmin);
break; break;
@@ -106,7 +106,7 @@ BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM
if (PickIconDlg(hWndDlg, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath), &grp.iIconIndex) == TRUE) if (PickIconDlg(hWndDlg, (LPWSTR)&grp.szIconPath, ARRAYSIZE(grp.szIconPath), &grp.iIconIndex) == TRUE)
{ {
// Since we've got the new icon... // Since we've got the new icon...
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex); hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)&grp.szIconPath, grp.iIconIndex);
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
} }
@@ -202,7 +202,7 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
itm.uiHotkeyVirtualKey = 0; itm.uiHotkeyVirtualKey = 0;
// Set the window title // Set the window title
LoadString(hAppInstance, IDS_DLT_ITEM_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle)); LoadString(g_hAppInstance, IDS_DLT_ITEM_NEW, szDlgTitle, ARRAYSIZE(szDlgTitle));
SetWindowText(hWndDlg, szDlgTitle); SetWindowText(hWndDlg, szDlgTitle);
// Populate the icon with the default path and index. // Populate the icon with the default path and index.
@@ -213,7 +213,7 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0); hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0);
// Set the icon in the dialog // Set the icon in the dialog
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex); hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex);
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
// Set the maximum input length of the text boxes // Set the maximum input length of the text boxes
@@ -314,14 +314,14 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
SetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)szNameBuffer); SetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)szNameBuffer);
// let's get the icon now // let's get the icon now
if (ExtractIcon(hAppInstance, (LPWSTR)szFileBuffer, -1) > 0) if (ExtractIcon(g_hAppInstance, (LPWSTR)szFileBuffer, -1) > 0)
{ {
// file contains at least one icon, set the itm struct values // file contains at least one icon, set the itm struct values
StringCchCopy(itm.szIconPath, ARRAYSIZE(itm.szIconPath), szFileBuffer); StringCchCopy(itm.szIconPath, ARRAYSIZE(itm.szIconPath), szFileBuffer);
itm.iIconIndex = 0; itm.iIconIndex = 0;
// update icon // update icon
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex);
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
} }
@@ -360,7 +360,7 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l
if (PickIconDlg(hWndDlg, (LPWSTR)&itm.szIconPath, ARRAYSIZE(itm.szIconPath), &itm.iIconIndex) == TRUE) if (PickIconDlg(hWndDlg, (LPWSTR)&itm.szIconPath, ARRAYSIZE(itm.szIconPath), &itm.iIconIndex) == TRUE)
{ {
// Since we've got the new icon... // Since we've got the new icon...
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); hIconDlg = ExtractIcon(g_hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex);
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
} }

View File

@@ -43,22 +43,22 @@ BOOL InitializeGroups(VOID)
RECT rcFrame; RECT rcFrame;
// Create the MDI Client Window // Create the MDI Client Window
ccs.hWindowMenu = GetSubMenu(GetMenu(hWndProgMgr), 2); ccs.hWindowMenu = GetSubMenu(GetMenu(g_hWndProgMgr), 2);
ccs.idFirstChild = IDM_WINDOW_CHILDSTART; ccs.idFirstChild = IDM_WINDOW_CHILDSTART;
GetClientRect(hWndProgMgr, &rcFrame); GetClientRect(g_hWndProgMgr, &rcFrame);
if ((hWndMDIClient = CreateWindowEx(WS_EX_COMPOSITED, if ((hWndMDIClient = CreateWindowEx(WS_EX_COMPOSITED,
TEXT("MDIClient"), NULL, WS_CLIPCHILDREN | WS_CHILD | TEXT("MDIClient"), NULL, WS_CLIPCHILDREN | WS_CHILD |
WS_VSCROLL | WS_HSCROLL | WS_VISIBLE, WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
rcFrame.left, rcFrame.top, rcFrame.right, rcFrame.bottom, rcFrame.left, rcFrame.top, rcFrame.right, rcFrame.bottom,
hWndProgMgr, (HMENU)1, hAppInstance, (LPWSTR)&ccs)) == NULL) g_hWndProgMgr, (HMENU)1, g_hAppInstance, (LPWSTR)&ccs)) == NULL)
{ {
return FALSE; return FALSE;
} }
// Load the group class string // Load the group class string
LoadString(hAppInstance, IDS_GRPCLASS, LoadString(g_hAppInstance, IDS_GRPCLASS,
szGrpClass, ARRAYSIZE(szGrpClass)); szGrpClass, ARRAYSIZE(szGrpClass));
// Register the group window class // Register the group window class
@@ -67,8 +67,8 @@ BOOL InitializeGroups(VOID)
wce.lpfnWndProc = GroupWndProc; wce.lpfnWndProc = GroupWndProc;
wce.cbClsExtra = 0; wce.cbClsExtra = 0;
wce.cbWndExtra = 0; wce.cbWndExtra = 0;
wce.hInstance = hAppInstance; wce.hInstance = g_hAppInstance;
wce.hIcon = hGroupIcon = LoadImage(hAppInstance, wce.hIcon = g_hGroupIcon = LoadImage(g_hAppInstance,
MAKEINTRESOURCE(IDI_PROGGRP), IMAGE_ICON, MAKEINTRESOURCE(IDI_PROGGRP), IMAGE_ICON,
0, 0, LR_DEFAULTSIZE | LR_SHARED); 0, 0, LR_DEFAULTSIZE | LR_SHARED);
wce.hCursor = LoadCursor(NULL, IDC_ARROW); wce.hCursor = LoadCursor(NULL, IDC_ARROW);
@@ -131,7 +131,7 @@ HWND CreateGroup(_In_ PGROUP pg)
mcs.szClass = szGrpClass; mcs.szClass = szGrpClass;
mcs.szTitle = pg->szName; mcs.szTitle = pg->szName;
mcs.hOwner = hAppInstance; mcs.hOwner = g_hAppInstance;
if ((pg->rcGroup.left == CW_USEDEFAULT) & (pg->rcGroup.right == CW_USEDEFAULT)) if ((pg->rcGroup.left == CW_USEDEFAULT) & (pg->rcGroup.right == CW_USEDEFAULT))
{ {
mcs.x = mcs.y = mcs.cx = mcs.cy = CW_USEDEFAULT; mcs.x = mcs.y = mcs.cx = mcs.cy = CW_USEDEFAULT;
@@ -175,7 +175,7 @@ HWND CreateGroup(_In_ PGROUP pg)
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
LVS_ICON | LVS_SINGLESEL | LVS_AUTOARRANGE, LVS_ICON | LVS_SINGLESEL | LVS_AUTOARRANGE,
mcs.x, mcs.y, mcs.cx, mcs.cy, mcs.x, mcs.y, mcs.cx, mcs.cy,
hWndGroup, NULL, hAppInstance, NULL)) == NULL) hWndGroup, NULL, g_hAppInstance, NULL)) == NULL)
return NULL; return NULL;
// ((LVS_AUTOARRANGE & bAutoArrange) * LVS_AUTOARRANGE) // ((LVS_AUTOARRANGE & bAutoArrange) * LVS_AUTOARRANGE)
@@ -290,7 +290,7 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi)
hImageList = ListView_GetImageList(hWndListView, LVSIL_NORMAL); hImageList = ListView_GetImageList(hWndListView, LVSIL_NORMAL);
// extract that icon son!! // extract that icon son!!
hIcon = ExtractIcon(hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex); hIcon = ExtractIcon(g_hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex);
// populate the listview with the relevant information // populate the listview with the relevant information
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
@@ -363,7 +363,7 @@ BOOL LoadItems(_In_ HWND hWndGroup)
pItem = pGroup->pItemArray + cItemIndex; pItem = pGroup->pItemArray + cItemIndex;
// extract that icon son!! // extract that icon son!!
hIcon = ExtractIcon(hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex); hIcon = ExtractIcon(g_hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex);
// populate the listview with the relevant information // populate the listview with the relevant information
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
@@ -415,7 +415,7 @@ BOOL RemoveItem(_In_ PITEM pi)
BOOL ExecuteItem(_In_ PITEM pi) BOOL ExecuteItem(_In_ PITEM pi)
{ {
// TODO: nCmdShow from program item flags // TODO: nCmdShow from program item flags
ShellExecute(hWndProgMgr, TEXT("open"), ShellExecute(g_hWndProgMgr, TEXT("open"),
pi->szExecPath, NULL, pi->szExecPath, NULL,
(pi->szWorkPath != TEXT("")) ? pi->szWorkPath : NULL, (pi->szWorkPath != TEXT("")) ? pi->szWorkPath : NULL,
SW_NORMAL); SW_NORMAL);

View File

@@ -19,27 +19,27 @@
/* Variables */ /* Variables */
// Global // Global
#ifdef _DEBUG #ifdef _DEBUG
BOOL bIsDebugBuild = TRUE; BOOL g_bIsDebugBuild = TRUE;
#else #else
BOOL bIsDebugBuild = FALSE; BOOL g_bIsDebugBuild = FALSE;
#endif #endif
BOOL bIsDefaultShell = FALSE; BOOL g_bIsDefaultShell = FALSE;
// Handles // Handles
HINSTANCE hAppInstance; HINSTANCE g_hAppInstance;
HANDLE hAppHeap; HANDLE g_hAppHeap;
HWND hWndProgMgr = NULL; HWND g_hWndProgMgr = NULL;
// Icons // Icons
HICON hProgMgrIcon = NULL; HICON g_hProgMgrIcon = NULL;
HICON hGroupIcon = NULL; HICON g_hGroupIcon = NULL;
// Global Strings // Global Strings
WCHAR szAppTitle[64]; WCHAR g_szAppTitle[64];
WCHAR szProgMgr[] = TEXT("progmgr"); WCHAR g_szProgMgr[] = TEXT("progmgr");
WCHAR szWebsite[64]; WCHAR g_szWebsite[64];
WCHAR szClass[16]; WCHAR g_szClass[16];
// Permissions // Permissions
BOOL bPermAdmin; // Has Administrator permissions BOOL g_bPermAdmin; // Has Administrator permissions
BOOL bPermGuest; // Has Guest permissions BOOL g_bPermGuest; // Has Guest permissions
BOOL bPermPower; // Has power option permissions BOOL g_bPermPower; // Has power option permissions
/* Functions */ /* Functions */
@@ -54,9 +54,9 @@ BOOL bPermPower; // Has power option permissions
BOOL UpdatePermissions(VOID) BOOL UpdatePermissions(VOID)
{ {
// SE_SHUTDOWN_NAME // SE_SHUTDOWN_NAME
bPermAdmin = FALSE; g_bPermAdmin = FALSE;
bPermGuest = FALSE; g_bPermGuest = FALSE;
bPermPower = FALSE; g_bPermPower = FALSE;
return FALSE; return FALSE;
} }
@@ -76,35 +76,35 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
POINT ptOffset = { 0 }; POINT ptOffset = { 0 };
// Initialize the instance // Initialize the instance
hAppInstance = hInstance; g_hAppInstance = hInstance;
// Create our global heap handle // Create our global heap handle
hAppHeap = GetProcessHeap(); g_hAppHeap = GetProcessHeap();
// Create Strings // Create Strings
LoadString(hAppInstance, IDS_PMCLASS, szClass, ARRAYSIZE(szClass)); LoadString(g_hAppInstance, IDS_PMCLASS, g_szClass, ARRAYSIZE(g_szClass));
LoadString(hAppInstance, IDS_APPTITLE, szAppTitle, ARRAYSIZE(szAppTitle)); LoadString(g_hAppInstance, IDS_APPTITLE, g_szAppTitle, ARRAYSIZE(g_szAppTitle));
LoadString(hAppInstance, IDS_WEBSITE, szWebsite, ARRAYSIZE(szWebsite)); LoadString(g_hAppInstance, IDS_WEBSITE, g_szWebsite, ARRAYSIZE(g_szWebsite));
// Get Desktop background color // Get Desktop background color
//CreateSolidBrush(GetBackgroundColor //CreateSolidBrush(GetBackgroundColor
// Register the Frame Window Class // Register the Frame Window Class
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
wc.hInstance = hAppInstance; wc.hInstance = g_hAppInstance;
wc.hIcon = hProgMgrIcon = LoadImage(hAppInstance, MAKEINTRESOURCE(IDI_PROGMGR), IMAGE_ICON, wc.hIcon = g_hProgMgrIcon = LoadImage(g_hAppInstance, MAKEINTRESOURCE(IDI_PROGMGR), IMAGE_ICON,
0, 0, LR_DEFAULTSIZE | LR_SHARED); 0, 0, LR_DEFAULTSIZE | LR_SHARED);
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
// wc.hbrBackground = (HBRUSH)(COLOR_BACKGROUND); // wc.hbrBackground = (HBRUSH)(COLOR_BACKGROUND);
wc.hbrBackground = NULL; wc.hbrBackground = NULL;
wc.lpszMenuName = MAKEINTRESOURCE(IDM_MAIN); wc.lpszMenuName = MAKEINTRESOURCE(IDM_MAIN);
wc.lpszClassName = szClass; wc.lpszClassName = g_szClass;
if (!RegisterClass(&wc)) if (!RegisterClass(&wc))
return FALSE; return FALSE;
// Load the Accelerator table // Load the Accelerator table
hAccel = LoadAccelerators(hAppInstance, MAKEINTRESOURCE(IDA_ACCELS)); hAccel = LoadAccelerators(g_hAppInstance, MAKEINTRESOURCE(IDA_ACCELS));
if (!hAccel) if (!hAccel)
return FALSE; return FALSE;
@@ -112,7 +112,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (!InitializeRegistryKeys()) if (!InitializeRegistryKeys())
return FALSE; return FALSE;
bIsDefaultShell = IsProgMgrDefaultShell(); g_bIsDefaultShell = IsProgMgrDefaultShell();
// Load configuration, but don't load groups yet // Load configuration, but don't load groups yet
if(LoadConfig(TRUE, TRUE, FALSE) != RCE_SUCCESS) if(LoadConfig(TRUE, TRUE, FALSE) != RCE_SUCCESS)
@@ -127,23 +127,23 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
// Create main window with a default size // Create main window with a default size
// TODO: i pulled 320x240 out of my ass, make this dynamic later // TODO: i pulled 320x240 out of my ass, make this dynamic later
if ((hWndProgMgr = CreateWindowW(wc.lpszClassName, szAppTitle, if ((g_hWndProgMgr = CreateWindowW(wc.lpszClassName, g_szAppTitle,
WS_OVERLAPPEDWINDOW | WS_VISIBLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
rcRoot.left + ptOffset.x, rcRoot.top + ptOffset.y, rcRoot.left + ptOffset.x, rcRoot.top + ptOffset.y,
rcRoot.left + ptOffset.x + 320, rcRoot.top + ptOffset.y + 240, rcRoot.left + ptOffset.x + 320, rcRoot.top + ptOffset.y + 240,
0, 0, hAppInstance, NULL)) == NULL) 0, 0, g_hAppInstance, NULL)) == NULL)
return 2; return 2;
// Set the window size from the registry, but only if the coords make sense // Set the window size from the registry, but only if the coords make sense
if ((rcMainWindow.left != rcMainWindow.right) && (rcMainWindow.top != rcMainWindow.bottom)) if ((rcMainWindow.left != rcMainWindow.right) && (rcMainWindow.top != rcMainWindow.bottom))
SetWindowPos(hWndProgMgr, NULL, SetWindowPos(g_hWndProgMgr, NULL,
rcMainWindow.left, rcMainWindow.top, rcMainWindow.left, rcMainWindow.top,
rcMainWindow.right - rcMainWindow.left, rcMainWindow.right - rcMainWindow.left,
rcMainWindow.bottom - rcMainWindow.top, SWP_NOZORDER); rcMainWindow.bottom - rcMainWindow.top, SWP_NOZORDER);
// Load the menus... // Load the menus...
hMenu = GetMenu(hWndProgMgr); hMenu = GetMenu(g_hWndProgMgr);
hSystemMenu = GetSystemMenu(hWndProgMgr, FALSE); hSystemMenu = GetSystemMenu(g_hWndProgMgr, FALSE);
// Update relevant parts of the window // Update relevant parts of the window
UpdateChecks(bAutoArrange, IDM_OPTIONS, IDM_OPTIONS_AUTOARRANGE); UpdateChecks(bAutoArrange, IDM_OPTIONS, IDM_OPTIONS_AUTOARRANGE);
@@ -156,21 +156,21 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
// Update settings based on their values // Update settings based on their values
if (bTopMost) if (bTopMost)
SetWindowPos(hWndProgMgr, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetWindowPos(g_hWndProgMgr, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if (bIsDefaultShell) if (g_bIsDefaultShell)
{ {
// Modify the context menus since we're the default shell // Modify the context menus since we're the default shell
DeleteMenu(hSystemMenu, SC_CLOSE, MF_BYCOMMAND); DeleteMenu(hSystemMenu, SC_CLOSE, MF_BYCOMMAND);
LoadString(hAppInstance, IDS_SHUTDOWN, szBuffer, ARRAYSIZE(szBuffer)); LoadString(g_hAppInstance, IDS_SHUTDOWN, szBuffer, ARRAYSIZE(szBuffer));
InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_SHUTDOWN, szBuffer); InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_SHUTDOWN, szBuffer);
ModifyMenu(hMenu, IDM_FILE_EXIT, MF_BYCOMMAND | MF_STRING, IDM_SHUTDOWN, szBuffer); ModifyMenu(hMenu, IDM_FILE_EXIT, MF_BYCOMMAND | MF_STRING, IDM_SHUTDOWN, szBuffer);
LoadString(hAppInstance, IDS_RUN, szBuffer, ARRAYSIZE(szBuffer)); LoadString(g_hAppInstance, IDS_RUN, szBuffer, ARRAYSIZE(szBuffer));
InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_FILE_RUN, szBuffer); InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_FILE_RUN, szBuffer);
LoadString(hAppInstance, IDS_TASKMGR, szBuffer, ARRAYSIZE(szBuffer)); LoadString(g_hAppInstance, IDS_TASKMGR, szBuffer, ARRAYSIZE(szBuffer));
InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_TASKMGR, szBuffer); InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_TASKMGR, szBuffer);
// Create the desktop window... // Create the desktop window...
@@ -184,7 +184,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
while (GetMessage(&msg, NULL, 0, 0) > 0) while (GetMessage(&msg, NULL, 0, 0) > 0)
{ {
if (!TranslateMDISysAccel(hWndMDIClient, &msg) && if (!TranslateMDISysAccel(hWndMDIClient, &msg) &&
!TranslateAccelerator(hWndProgMgr, hAccel, &msg)) !TranslateAccelerator(g_hWndProgMgr, hAccel, &msg))
{ {
DispatchMessage(&msg); DispatchMessage(&msg);
} }

View File

@@ -15,6 +15,7 @@
#pragma comment(lib, "Secur32.lib") #pragma comment(lib, "Secur32.lib")
#pragma comment(lib, "UxTheme.lib") #pragma comment(lib, "UxTheme.lib")
#pragma comment(lib, "Version.lib") #pragma comment(lib, "Version.lib")
#pragma comment(lib, "Winmm.lib")
/* Macros and Defines */ /* Macros and Defines */
#define GET_WM_COMMAND_ID(wParam, lParam) LOWORD(wParam) #define GET_WM_COMMAND_ID(wParam, lParam) LOWORD(wParam)
@@ -30,23 +31,23 @@
#define RF_RETRY 0x0002 // Cancel the operation, but leave the dialog open #define RF_RETRY 0x0002 // Cancel the operation, but leave the dialog open
/* Global Variables */ /* Global Variables */
extern BOOL bIsDefaultShell; extern BOOL g_bIsDefaultShell;
// Handles // Handles
extern HINSTANCE hAppInstance; extern HINSTANCE g_hAppInstance;
extern HANDLE hAppHeap; extern HANDLE g_hAppHeap;
extern HWND hWndProgMgr; extern HWND g_hWndProgMgr;
// Icons // Icons
extern HICON hProgMgrIcon; extern HICON g_hProgMgrIcon;
extern HICON hGroupIcon; extern HICON g_hGroupIcon;
// Strings // Strings
extern WCHAR szAppTitle[64]; extern WCHAR g_szAppTitle[64];
extern WCHAR szProgMgr[]; extern WCHAR g_szProgMgr[];
extern WCHAR szWebsite[64]; extern WCHAR g_szWebsite[64];
extern WCHAR szClass[16]; extern WCHAR g_szClass[16];
// Permissions // Permissions
extern BOOL bPermAdmin; // Has Administrator permissions extern BOOL g_bPermAdmin; // Has Administrator permissions
extern BOOL bPermGuest; // Has Guest permissions extern BOOL g_bPermGuest; // Has Guest permissions
extern BOOL bPermPower; // Has power option permissions extern BOOL g_bPermPower; // Has power option permissions
/* Function Prototypes */ /* Function Prototypes */
BOOL UpdatePermissions(VOID); BOOL UpdatePermissions(VOID);

View File

@@ -54,13 +54,13 @@ PWSTR pszSettingsMask = TEXT("SettingsMask");
\* * * */ \* * * */
BOOL InitializeRegistryKeys(VOID) BOOL InitializeRegistryKeys(VOID)
{ {
if (!RegCreateKeyEx(HKEY_CURRENT_USER, PROGMGR_KEY, 0, szProgMgr, 0, if (!RegCreateKeyEx(HKEY_CURRENT_USER, PROGMGR_KEY, 0, g_szProgMgr, 0,
KEY_READ | KEY_WRITE, NULL, &hKeyProgramManager, NULL)) KEY_READ | KEY_WRITE, NULL, &hKeyProgramManager, NULL))
{ {
// Create Program Groups and Settings keys // Create Program Groups and Settings keys
RegCreateKeyEx(hKeyProgramManager, pszProgramGroups, 0, szProgMgr, 0, RegCreateKeyEx(hKeyProgramManager, pszProgramGroups, 0, g_szProgMgr, 0,
KEY_READ | KEY_WRITE, NULL, &hKeyProgramGroups, NULL); KEY_READ | KEY_WRITE, NULL, &hKeyProgramGroups, NULL);
RegCreateKeyEx(hKeyProgramManager, pszSettings, 0, szProgMgr, 0, RegCreateKeyEx(hKeyProgramManager, pszSettings, 0, g_szProgMgr, 0,
KEY_READ | KEY_WRITE, NULL, &hKeySettings, NULL); KEY_READ | KEY_WRITE, NULL, &hKeySettings, NULL);
return TRUE; return TRUE;
@@ -88,7 +88,7 @@ BOOL IsProgMgrDefaultShell(VOID)
if (RegQueryValueEx(hKeyWinlogon, TEXT("Shell"), 0, &dwType, if (RegQueryValueEx(hKeyWinlogon, TEXT("Shell"), 0, &dwType,
(LPBYTE)szShell, &dwBufferSize) == ERROR_SUCCESS) (LPBYTE)szShell, &dwBufferSize) == ERROR_SUCCESS)
{ {
if (StrStr(szShell, szProgMgr)) if (StrStr(szShell, g_szProgMgr))
{ {
// ProgMgr detected >:) // ProgMgr detected >:)
RegCloseKey(hKeyWinlogon); RegCloseKey(hKeyWinlogon);
@@ -170,7 +170,7 @@ DWORD SaveConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups, _In_ BO
// Get and save window position // Get and save window position
wpProgMgr.length = sizeof(WINDOWPLACEMENT); wpProgMgr.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hWndProgMgr, &wpProgMgr); GetWindowPlacement(g_hWndProgMgr, &wpProgMgr);
CopyRect(&rcWindow, &wpProgMgr.rcNormalPosition); CopyRect(&rcWindow, &wpProgMgr.rcNormalPosition);
if (!RegSetValueEx(hKeySettings, pszSettingsWindow, 0, REG_BINARY, if (!RegSetValueEx(hKeySettings, pszSettingsWindow, 0, REG_BINARY,

View File

@@ -15,6 +15,7 @@
#include <shellapi.h> #include <shellapi.h>
#include <Lmcons.h> #include <Lmcons.h>
#include <security.h> #include <security.h>
#include <Mmsystem.h>
#include "progmgr.h" #include "progmgr.h"
#include "dialog.h" #include "dialog.h"
#include "group.h" #include "group.h"
@@ -36,6 +37,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CREATE: case WM_CREATE:
{ {
// Play the logon sound. (But only if we're the default shell)
if (g_bIsDefaultShell)
PlaySound(TEXT("WindowsLogon"), NULL, SND_ALIAS | SND_ASYNC);
return TRUE; return TRUE;
} }
@@ -46,7 +50,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
if (wParam == IDM_TASKMGR) if (wParam == IDM_TASKMGR)
{ {
ShellExecute(hWndProgMgr, TEXT("open"), TEXT("TASKMGR.EXE"), NULL, NULL, SW_NORMAL); ShellExecute(g_hWndProgMgr, TEXT("open"), TEXT("TASKMGR.EXE"), NULL, NULL, SW_NORMAL);
return 0; return 0;
} }
@@ -67,7 +71,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (bSaveSettings) if (bSaveSettings)
SaveConfig(TRUE, TRUE, TRUE, TRUE); SaveConfig(TRUE, TRUE, TRUE, TRUE);
if (bIsDefaultShell && (GetShellWindow() != NULL)) if (g_bIsDefaultShell && (GetShellWindow() != NULL))
SetShellWindow(0); SetShellWindow(0);
PostQuitMessage(0); PostQuitMessage(0);
@@ -96,15 +100,15 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
{ {
case IDM_SHUTDOWN: case IDM_SHUTDOWN:
DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_POWER), hWnd, (DLGPROC)ShutdownDlgProc); DialogBox(g_hAppInstance, MAKEINTRESOURCE(DLG_POWER), hWnd, (DLGPROC)ShutdownDlgProc);
break; break;
case IDM_FILE_NEW_GROUP: case IDM_FILE_NEW_GROUP:
DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_GROUP), hWnd, (DLGPROC)NewGroupDlgProc); DialogBox(g_hAppInstance, MAKEINTRESOURCE(DLG_GROUP), hWnd, (DLGPROC)NewGroupDlgProc);
break; break;
case IDM_FILE_NEW_ITEM: case IDM_FILE_NEW_ITEM:
DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_ITEM), hWnd, (DLGPROC)NewItemDlgProc); DialogBox(g_hAppInstance, MAKEINTRESOURCE(DLG_ITEM), hWnd, (DLGPROC)NewItemDlgProc);
break; break;
case IDM_FILE_RUN: case IDM_FILE_RUN:
@@ -127,7 +131,7 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
case IDM_OPTIONS_TOPMOST: case IDM_OPTIONS_TOPMOST:
bTopMost = !bTopMost; bTopMost = !bTopMost;
SetWindowPos(hWndProgMgr, bTopMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetWindowPos(g_hWndProgMgr, bTopMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
UpdateChecks(bTopMost, IDM_OPTIONS, IDM_OPTIONS_TOPMOST); UpdateChecks(bTopMost, IDM_OPTIONS, IDM_OPTIONS_TOPMOST);
goto SaveConfig; goto SaveConfig;
@@ -164,15 +168,15 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
break; break;
case IDM_HELP_INDEX: case IDM_HELP_INDEX:
ShellExecute(NULL, TEXT("open"), szWebsite, NULL, NULL, SW_SHOWNORMAL); ShellExecute(NULL, TEXT("open"), g_szWebsite, NULL, NULL, SW_SHOWNORMAL);
break; break;
case IDM_HELP_ABOUT: case IDM_HELP_ABOUT:
{ {
WCHAR szTitle[40]; WCHAR szTitle[40];
LoadString(hAppInstance, IDS_APPTITLE, szTitle, ARRAYSIZE(szTitle)); LoadString(g_hAppInstance, IDS_APPTITLE, szTitle, ARRAYSIZE(szTitle));
ShellAbout(hWndProgMgr, szTitle, NULL, hProgMgrIcon); ShellAbout(g_hWndProgMgr, szTitle, NULL, g_hProgMgrIcon);
break; break;
} }
@@ -205,7 +209,7 @@ VOID UpdateChecks(BOOL bVarMenu, UINT uSubMenu, UINT uID)
{ {
HMENU hMenu; HMENU hMenu;
hMenu = GetMenu(hWndProgMgr); hMenu = GetMenu(g_hWndProgMgr);
CheckMenuItem(hMenu, uID, (WORD)(bVarMenu ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(hMenu, uID, (WORD)(bVarMenu ? MF_CHECKED : MF_UNCHECKED));
return; return;
@@ -222,13 +226,13 @@ VOID UpdateWindowTitle(VOID)
{ {
WCHAR szUsername[UNLEN + 1] = TEXT(""); WCHAR szUsername[UNLEN + 1] = TEXT("");
DWORD dwUsernameLen = UNLEN; DWORD dwUsernameLen = UNLEN;
WCHAR szWindowTitle[UNLEN + ARRAYSIZE(szAppTitle) + 4] = TEXT(""); WCHAR szWindowTitle[UNLEN + ARRAYSIZE(g_szAppTitle) + 4] = TEXT("");
// Get user and domain name // Get user and domain name
GetUserNameEx(NameSamCompatible, szUsername, &dwUsernameLen); GetUserNameEx(NameSamCompatible, szUsername, &dwUsernameLen);
// Add username to window title if settings permit // Add username to window title if settings permit
StringCchCopy(szWindowTitle, ARRAYSIZE(szAppTitle), szAppTitle); StringCchCopy(szWindowTitle, ARRAYSIZE(g_szAppTitle), g_szAppTitle);
if (bShowUsername) if (bShowUsername)
{ {
@@ -236,7 +240,7 @@ VOID UpdateWindowTitle(VOID)
StringCchCat(szWindowTitle, ARRAYSIZE(szWindowTitle), szUsername); StringCchCat(szWindowTitle, ARRAYSIZE(szWindowTitle), szUsername);
} }
SetWindowText(hWndProgMgr, (LPCWSTR)&szWindowTitle); SetWindowText(g_hWndProgMgr, (LPCWSTR)&szWindowTitle);
return; return;
} }