diff --git a/progmgr/progmgr.c b/progmgr/progmgr.c index 026090b..0e2b526 100644 --- a/progmgr/progmgr.c +++ b/progmgr/progmgr.c @@ -2,7 +2,7 @@ PROGMGR.C - Copyright (c) 2023 freedom7341, Freedom Desktop DESCRIPTION - - Program Manager's main file, including wWinMain! + Program Manager's main file, now with extra wWinMain! LICENSE INFORMATION - MIT License, see LICENSE.txt in the root folder \* * * * * * * */ @@ -24,11 +24,7 @@ HWND hwndProgMgr = NULL; HWND hwndMDIClient = NULL; // Global Strings WCHAR szAppTitle[32]; - -/* Registry Keys */ - -// ... -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +WCHAR szProgMgr[] = L"progmgr"; /* Program Entry Point */ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) @@ -43,6 +39,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine LoadString(hAppInstance, IDS_APPTITLE, szAppTitle, CharSizeOf(szAppTitle)); LoadString(hAppInstance, IDS_PMCLASS, szClass, CharSizeOf(szClass)); + // And add Task Manager... // LoadString(hAppInstance, IDS_TASKMGR, szBuffer, CharSizeOf(szBuffer)); // InsertMenu(hSystemMenu, 6, MF_BYPOSITION | MF_STRING, IDM_TASKMGR, szBuffer); @@ -59,63 +56,20 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine return 1; InitializeRegistryKeys(); + //if (IsProgMgrDefaultShell) { + + //} if (!CreateWindow(wc.lpszClassName, szAppTitle, WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 0, 0, 640, 480, 0, 0, hInstance, NULL)) + 160, 80, 640, 480, 0, 0, hInstance, NULL)) return 2; + //hSystemMenu = GetSystemMenu(hwndProgman, FALSE); + while (GetMessage(&msg, NULL, 0, 0) > 0) DispatchMessage(&msg); return 0; } - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - - switch (message) - { - case WM_CREATE: - { - RECT rc; - CLIENTCREATESTRUCT ccs; - - hwndProgMgr = hWnd; - - // ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), IDM_WINDOW); - // ccs.idFirstChild = IDM_CHILDSTART; - - GetClientRect(hwndProgMgr, &rc); - - hwndMDIClient = CreateWindow(TEXT("MDIClient"), - NULL, - WS_CLIPCHILDREN | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_BORDER, - rc.left - 1, rc.top - 1, - rc.right + 2, rc.bottom + 2, - hWnd, (HMENU)1, hAppInstance, - (LPTSTR)&ccs); - if (!hwndMDIClient) { - return -1; - } - - break; - } - //case WM_SYSCOMMAND: - //{ - // if (wParam == IDM_TASKMGR) { - //ShellExecute(hwndProgMgr, &TEXT("OPEN\0"), &TEXT("TASKMGR.EXE\0"), NULL, NULL, SW_NORMAL); - // break; - // } - //break; - //} - case WM_CLOSE: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; - -} diff --git a/progmgr/progmgr.h b/progmgr/progmgr.h index 4da7301..be5e0ff 100644 --- a/progmgr/progmgr.h +++ b/progmgr/progmgr.h @@ -13,6 +13,21 @@ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +/* Includes */ +#include + /* Macros and Defines */ #define CharSizeOf(x) (sizeof(x) / sizeof(*x)) +/* Global Variables */ +// PROGMGR.C +extern BOOL bIsDefaultShell; +extern HINSTANCE hAppInstance; +extern HWND hwndProgMgr; +extern HWND hwndMDIClient; +extern WCHAR szAppTitle[32]; +extern WCHAR szProgMgr[]; + +/* Function Prototypes */ +// WNDPROC.C +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/progmgr/progmgr.vcxproj b/progmgr/progmgr.vcxproj index ddba5f3..ea788dc 100644 --- a/progmgr/progmgr.vcxproj +++ b/progmgr/progmgr.vcxproj @@ -158,6 +158,7 @@ + diff --git a/progmgr/registry.c b/progmgr/registry.c index 4b7b0e0..6858614 100644 --- a/progmgr/registry.c +++ b/progmgr/registry.c @@ -30,4 +30,37 @@ BOOL InitializeRegistryKeys() return TRUE; } return FALSE; -} \ No newline at end of file +} + +/* * * *\ + IsProgMgrDefaultShell - + Detects if Program Manager is the default shell. + RETURNS - + True if successful, false if unsuccessful. +\* * * */ +#if 0 +BOOL IsProgMgrDefaultShell() +{ + HKEY hkeyWinlogon; + DWORD dwType; + DWORD cbBuffer; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SHELL_KEY, 0, KEY_READ, &hkeyWinlogon) == ERROR_SUCCESS) { + cbBuffer = sizeof(szBuffer); + if (RegQueryValueEx(hkeyWinlogon, L"Shell", 0, NULL, (LPBYTE)szBuffer, &cbBuffer) == ERROR_SUCCESS) { + CharLower(szBuffer); + lpt = szBuffer; + while (lpt = wcsstr(lpt, szProgmgr)) { + // we probably found progman + lpt += lstrlen(szProgmgr); + if (*lpt == TEXT(' ') || *lpt == TEXT('.') || *lpt == TEXT(',') || !*lpt) + bExitWindows = TRUE; + } + } + else { + // assume that progman is the shell. + bExitWindows = TRUE; + } + return FALSE; +} +#endif \ No newline at end of file diff --git a/progmgr/registry.h b/progmgr/registry.h index 7f39a4e..eec17c3 100644 --- a/progmgr/registry.h +++ b/progmgr/registry.h @@ -14,6 +14,7 @@ #include /* Defines */ +#define SHELL_KEY L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" #define PROGMAN_KEY L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Program Manager" #define WINDOWS_KEY L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows" #define PROGMGR_KEY L"Software\\Freedom Desktop\\Program Manager II" @@ -25,3 +26,4 @@ /* Function Prototypes */ BOOL InitializeRegistryKeys(VOID); +BOOL IsProgMgrDefaultShell(VOID); diff --git a/progmgr/wndproc.c b/progmgr/wndproc.c new file mode 100644 index 0000000..3d291fe --- /dev/null +++ b/progmgr/wndproc.c @@ -0,0 +1,71 @@ +/* * * * * * * *\ + WNDPROC.C - + Copyright (c) 2023 freedom7341, Freedom Desktop + DESCRIPTION - + Program Manager's window procedure. + LICENSE INFORMATION - + MIT License, see LICENSE.txt in the root folder +\* * * * * * * */ + +/* Headers */ +#include "progmgr.h" +#include "resource.h" +#include "registry.h" +// #define WIN32_LEAN_AND_MEAN +#include + +/* Functions */ + +/* * * *\ + WndProc - + Program Manager's window procedure. + RETURNS - + Zero if nothing, otherwise returns the good stuff. +\* * * */ +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + + switch (message) + { + case WM_CREATE: + { + RECT rc; + CLIENTCREATESTRUCT ccs; + + hwndProgMgr = hWnd; + + // ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), IDM_WINDOW); + // ccs.idFirstChild = IDM_CHILDSTART; + + GetClientRect(hwndProgMgr, &rc); + + hwndMDIClient = CreateWindow(TEXT("MDIClient"), + NULL, + WS_CLIPCHILDREN | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_BORDER, + rc.left - 1, rc.top - 1, + rc.right + 2, rc.bottom + 2, + hWnd, (HMENU)1, hAppInstance, + (LPTSTR)&ccs); + if (!hwndMDIClient) { + return -1; + } + + break; + } + //case WM_SYSCOMMAND: + //{ + // if (wParam == IDM_TASKMGR) { + //ShellExecute(hwndProgMgr, &TEXT("OPEN\0"), &TEXT("TASKMGR.EXE\0"), NULL, NULL, SW_NORMAL); + // break; + // } + //break; + //} + case WM_CLOSE: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; + +}