diff --git a/progmgr/lang/res_en-US.rc b/progmgr/lang/res_en-US.rc index c0bf2fb..3ce2278 100644 Binary files a/progmgr/lang/res_en-US.rc and b/progmgr/lang/res_en-US.rc differ diff --git a/progmgr/progmgr.c b/progmgr/progmgr.c index 0e2b526..c800a53 100644 --- a/progmgr/progmgr.c +++ b/progmgr/progmgr.c @@ -15,16 +15,17 @@ #include /* Variables */ -// Miscellaneous +// Global BOOL bIsDefaultShell = FALSE; +// Global Strings +WCHAR szAppTitle[32]; +WCHAR szProgMgr[] = L"progmgr"; +WCHAR szWebsite[64]; // Window Related HICON hProgMgrIcon = NULL; HINSTANCE hAppInstance; HWND hwndProgMgr = NULL; HWND hwndMDIClient = NULL; -// Global Strings -WCHAR szAppTitle[32]; -WCHAR szProgMgr[] = L"progmgr"; /* Program Entry Point */ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) @@ -38,7 +39,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine // Create Important Strings LoadString(hAppInstance, IDS_APPTITLE, szAppTitle, CharSizeOf(szAppTitle)); LoadString(hAppInstance, IDS_PMCLASS, szClass, CharSizeOf(szClass)); - + LoadString(hAppInstance, IDS_WEBSITE, szWebsite, CharSizeOf(szWebsite)); // And add Task Manager... // LoadString(hAppInstance, IDS_TASKMGR, szBuffer, CharSizeOf(szBuffer)); diff --git a/progmgr/progmgr.h b/progmgr/progmgr.h index be5e0ff..855680e 100644 --- a/progmgr/progmgr.h +++ b/progmgr/progmgr.h @@ -17,7 +17,18 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #include /* Macros and Defines */ +#define GET_WM_COMMAND_ID(wParam, lParam) LOWORD(wParam) #define CharSizeOf(x) (sizeof(x) / sizeof(*x)) +// RunFileDlg flags +#define RFF_NOBROWSE 0x0001 // Removes the browse button +#define RFF_NODEFAULT 0x0002 // No default item selected +#define RFF_CALCDIRECTORY 0x0004 // Calculates the working directory from the file name +#define RFF_NOLABEL 0x0008 // Removes the edit box label +#define RFF_NOSEPARATEMEM 0x0020 // Removes the Separate Memory Space check box, NT only +// RunFileDlg notification return values +#define RF_OK 0x0000 // Allow the application to run +#define RF_CANCEL 0x0001 // Cancel the operation and close the dialog +#define RF_RETRY 0x0002 // Cancel the operation, but leave the dialog open /* Global Variables */ // PROGMGR.C @@ -27,7 +38,12 @@ extern HWND hwndProgMgr; extern HWND hwndMDIClient; extern WCHAR szAppTitle[32]; extern WCHAR szProgMgr[]; +extern WCHAR szWebsite[64]; /* Function Prototypes */ +// SHELLINT.C +BOOL RunFile(HWND hWndOwner, HICON hIcon, LPWSTR lpszDir, LPWSTR lpszTitle, LPWSTR lpszDesc, DWORD dwFlags); +BOOL ShutdownDlg(HWND hWndOwner); // WNDPROC.C LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam); diff --git a/progmgr/progmgr.vcxproj b/progmgr/progmgr.vcxproj index ea788dc..3a9056e 100644 --- a/progmgr/progmgr.vcxproj +++ b/progmgr/progmgr.vcxproj @@ -158,6 +158,7 @@ + diff --git a/progmgr/registry.c b/progmgr/registry.c index 6858614..3c66896 100644 --- a/progmgr/registry.c +++ b/progmgr/registry.c @@ -13,7 +13,6 @@ #include /* Functions */ - /* * * *\ InitializeRegistryKeys - Takes the relevant Registry Keys and turns them @@ -38,29 +37,22 @@ BOOL InitializeRegistryKeys() RETURNS - True if successful, false if unsuccessful. \* * * */ -#if 0 BOOL IsProgMgrDefaultShell() { HKEY hkeyWinlogon; - DWORD dwType; - DWORD cbBuffer; + //DWORD szShell; + //DWORD cbBuffer = 0; 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)) { + //if (RegQueryValueEx(hkeyWinlogon, L"Shell", 0, NULL, szShell, &cbBuffer) == ERROR_SUCCESS) { // we probably found progman - lpt += lstrlen(szProgmgr); - if (*lpt == TEXT(' ') || *lpt == TEXT('.') || *lpt == TEXT(',') || !*lpt) - bExitWindows = TRUE; - } - } - else { + //} + } + else { // assume that progman is the shell. - bExitWindows = TRUE; - } + } + + RegCloseKey(hkeyWinlogon); + return FALSE; -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/progmgr/registry.h b/progmgr/registry.h index eec17c3..9fecdde 100644 --- a/progmgr/registry.h +++ b/progmgr/registry.h @@ -18,7 +18,7 @@ #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" -#define REGKEYMAXLENGTH 261 +#define HKEYMAXLENGTH 261 /* Global Registry Keys */ //HKEY hkeyProgramManager; diff --git a/progmgr/resource.h b/progmgr/resource.h index bf42fc1..657cf34 100644 Binary files a/progmgr/resource.h and b/progmgr/resource.h differ diff --git a/progmgr/shellint.c b/progmgr/shellint.c new file mode 100644 index 0000000..575377a --- /dev/null +++ b/progmgr/shellint.c @@ -0,0 +1,59 @@ +/* * * * * * * *\ + SHELLINT.C - + Copyright (c) 2023 freedom7341, Freedom Desktop + DESCRIPTION - + Program Manager's shell interface functions. + LICENSE INFORMATION - + MIT License, see LICENSE.txt in the root folder +\* * * * * * * */ + +/* Headers */ +#include "progmgr.h" +#define WIN32_LEAN_AND_MEAN +#include + +/* Functions */ +/* * * *\ + RunFile - + Produces a Run dialog window. + RETURNS - + True if successful, false if unsuccessful. +\* * * */ +BOOL RunFile(HWND hWndOwner, + HICON hIcon, + LPWSTR lpszDir, + LPWSTR lpszTitle, + LPWSTR lpszDesc, + DWORD dwFlags) +{ + HMODULE hLib = LoadLibrary(L"shell32.dll"); + + if (hLib) { + FARPROC fLib = GetProcAddress(hLib, MAKEINTRESOURCEA(61)); + if (fLib(hWndOwner, hIcon, lpszDir, lpszTitle, lpszDesc, dwFlags)) + FreeLibrary(hLib); + return TRUE; + } + + return 0; +} + +/* * * *\ + ShutdownDlg - + Produces a Shutdown dialog window. + RETURNS - + True if successful, false if unsuccessful. +\* * * */ +BOOL ShutdownDlg(HWND hWndOwner) +{ + HMODULE hLib = LoadLibrary(L"shell32.dll"); + + if (hLib) { + FARPROC fLib = GetProcAddress(hLib, MAKEINTRESOURCEA(60)); + if (fLib(hWndOwner)) + FreeLibrary(hLib); + return TRUE; + } + + return 0; +} diff --git a/progmgr/wndproc.c b/progmgr/wndproc.c index 3d291fe..ac3ff7b 100644 --- a/progmgr/wndproc.c +++ b/progmgr/wndproc.c @@ -25,8 +25,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) - { + switch (message) { + case WM_CREATE: { RECT rc; @@ -49,23 +49,82 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (!hwndMDIClient) { return -1; } - break; } - //case WM_SYSCOMMAND: - //{ + + case WM_SYSCOMMAND: + { // if (wParam == IDM_TASKMGR) { //ShellExecute(hwndProgMgr, &TEXT("OPEN\0"), &TEXT("TASKMGR.EXE\0"), NULL, NULL, SW_NORMAL); // break; // } //break; - //} + if (wParam == IDM_FILE_SHUTDOWN) { + CmdProc(hWnd, wParam, lParam); + break; + } + if (wParam == IDM_FILE_RUN) { + CmdProc(hWnd, wParam, lParam); + break; + } + goto WndProcDefault; + //return DefFrameProc(hWnd, hwndMDIClient, uiMsg, wParam, lParam); + } + + case WM_COMMAND: + if (CmdProc(hWnd, wParam, lParam)) { + break; + } + goto WndProcDefault; + case WM_CLOSE: PostQuitMessage(0); break; + default: +WndProcDefault: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } + +/* * * *\ + CmdProc - + Program Manager's syscommand procedure. + RETURNS - + Zero if nothing, otherwise returns the good stuff. +\* * * */ +LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + switch (GET_WM_COMMAND_ID(wParam, lParam)) { + + case IDM_FILE_RUN: + RunFile(hWnd, NULL, NULL, NULL, NULL, RFF_CALCDIRECTORY); + break; + + case IDM_FILE_SHUTDOWN: + ShutdownDlg(hWnd); + break; + + case IDM_HELP_INDEX: + ShellExecute(NULL, L"open", szWebsite, NULL, NULL, SW_SHOWNORMAL); + break; + + case IDM_HELP_ABOUT: + { + WCHAR szTitle[40]; + OutputDebugString(L"ABOUT BALLS!"); + HICON hIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(PROGMGRICON)); + + LoadString(hAppInstance, IDS_APPTITLE, szTitle, CharSizeOf(szTitle)); + ShellAbout(hwndProgMgr, szTitle, NULL, hIcon); + break; + } + + default: + return FALSE; + } + + return TRUE; +} \ No newline at end of file