diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index 0d44743ed67..debcfac3c68 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -45,7 +45,7 @@ static BOOL (WINAPI*SetShellWindowEx)(HWND, HWND); BOOL IsAnyDesktopRunning() { - HINSTANCE shell32 = GetModuleHandle(_T("user32")); + HINSTANCE shell32 = GetModuleHandle(TEXT("user32")); SetShellWindow = (BOOL(WINAPI*)(HWND)) GetProcAddress(shell32, "SetShellWindow"); SetShellWindowEx = (BOOL(WINAPI*)(HWND,HWND)) GetProcAddress(shell32, "SetShellWindowEx"); @@ -71,7 +71,7 @@ static void draw_desktop_background(HWND hwnd, HDC hdc) rect.bottom = rect.top + 40; #include "../buildno.h" - static const LPCTSTR BkgndText = _T("ReactOS ")_T(KERNEL_VERSION_STR)_T(" Explorer\nby Martin Fuchs"); + static const LPCTSTR BkgndText = TEXT("ReactOS ")TEXT(KERNEL_VERSION_STR)TEXT(" Explorer\nby Martin Fuchs"); BkMode bkMode(hdc, TRANSPARENT); @@ -119,14 +119,14 @@ DesktopWindow::~DesktopWindow() HWND DesktopWindow::Create() { - IconWindowClass wcDesktop(_T("Progman"), IDI_REACTOS, CS_DBLCLKS); + IconWindowClass wcDesktop(TEXT("Progman"), IDI_REACTOS, CS_DBLCLKS); wcDesktop.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1); int width = GetSystemMetrics(SM_CXSCREEN); int height = GetSystemMetrics(SM_CYSCREEN); HWND hwndDesktop = Window::Create(WINDOW_CREATOR(DesktopWindow), - WS_EX_TOOLWINDOW, wcDesktop, _T("Program Manager"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, + WS_EX_TOOLWINDOW, wcDesktop, TEXT("Program Manager"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, 0, 0, width, height, 0); // work around to display desktop bar in Wine diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index f350761dbc6..704629fcf3d 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -38,7 +38,9 @@ #include "explorer_intres.h" -#include +#include // for setlocale() +#include // for dup2() +#include // for _O_RDONLY ExplorerGlobals g_Globals; @@ -52,6 +54,7 @@ ExplorerGlobals::ExplorerGlobals() _hMainWnd = 0; _prescan_nodes = false; _desktop_mode = false; + _log = NULL; } @@ -162,10 +165,14 @@ int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int); int main(int argc, char* argv[]) { STARTUPINFO startupinfo; + int nShowCmd = SW_SHOWNORMAL; GetStartupInfo(&startupinfo); - return wWinMain(GetModuleHandle(NULL), 0, GetCommandLine(), startupinfo.wShowWindow); + if (startupinfo.dwFlags & STARTF_USESHOWWINDOW) + nShowCmd = startupinfo.wShowWindow; + + return wWinMain(GetModuleHandle(NULL), 0, GetCommandLine(), nShowCmd); } #endif // __MINGW && UNICODE @@ -195,9 +202,20 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL startup_desktop = TRUE; } - if (!_tcsstr(lpCmdLine,TEXT("-noautostart"))) + if (_tcsstr(lpCmdLine,TEXT("-noautostart"))) autostart = false; + if (_tcsstr(lpCmdLine,TEXT("-console"))) { + AllocConsole(); + + _dup2(_open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE), _O_RDONLY), 0); + _dup2(_open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), 0), 1); + _dup2(_open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE), 0), 2); + + g_Globals._log = fdopen(1, "w"); + setvbuf(g_Globals._log, 0, _IONBF, 0); + } + g_Globals._hInstance = hInstance; HWND hwndDesktop = 0; diff --git a/reactos/subsys/system/explorer/globals.h b/reactos/subsys/system/explorer/globals.h index 1d2351f7231..f61adde472d 100644 --- a/reactos/subsys/system/explorer/globals.h +++ b/reactos/subsys/system/explorer/globals.h @@ -36,8 +36,12 @@ extern struct ExplorerGlobals HWND _hMainWnd; bool _prescan_nodes; bool _desktop_mode; + + FILE* _log; } g_Globals; +#define LOG(x) if (g_Globals._log) _ftprintf(g_Globals._log, TEXT("%s\n"), (LPCTSTR)(x)); + struct ResString : public String { diff --git a/reactos/subsys/system/explorer/shell/pane.cpp b/reactos/subsys/system/explorer/shell/pane.cpp index 603b9c30fda..eee95bc0e67 100644 --- a/reactos/subsys/system/explorer/shell/pane.cpp +++ b/reactos/subsys/system/explorer/shell/pane.cpp @@ -193,8 +193,8 @@ void Pane::init() HKEY hkeyExplorer = 0; DWORD len = sizeof(_clrCompressed); - if (RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"), &hkeyExplorer) || - RegQueryValueEx(hkeyExplorer, _T("AltColor"), 0, NULL, (LPBYTE)&_clrCompressed, &len) || len!=sizeof(_clrCompressed)) + if (RegOpenKey(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"), &hkeyExplorer) || + RegQueryValueEx(hkeyExplorer, TEXT("AltColor"), 0, NULL, (LPBYTE)&_clrCompressed, &len) || len!=sizeof(_clrCompressed)) _clrCompressed = RGB(0,0,255); if (hkeyExplorer) diff --git a/reactos/subsys/system/explorer/shell/shellfs.cpp b/reactos/subsys/system/explorer/shell/shellfs.cpp index 1ffb76f3a74..d405f1297c6 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.cpp +++ b/reactos/subsys/system/explorer/shell/shellfs.cpp @@ -35,11 +35,11 @@ #include "shellfs.h" -bool ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA* pw32fdata, BY_HANDLE_FILE_INFORMATION* pbhfi, bool access) +bool ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA* pw32fdata, BY_HANDLE_FILE_INFORMATION* pbhfi, bool do_access) { bool bhfi_valid = false; - if (access && !( (attribs & SFGAO_FILESYSTEM) && SUCCEEDED( + if (do_access && !( (attribs&SFGAO_FILESYSTEM) && SUCCEEDED( SHGetDataFromIDList(_folder, pidl, SHGDFIL_FINDDATA, pw32fdata, sizeof(WIN32_FIND_DATA))) )) { WIN32_FILE_ATTRIBUTE_DATA fad; IDataObject* pDataObj; @@ -88,7 +88,7 @@ bool ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN } } - if (!(attribs & SFGAO_FILESYSTEM) || !access) // Archiv files should not be displayed as folders in explorer view. + if (!do_access || !(attribs&SFGAO_FILESYSTEM)) // Archiv files should not be displayed as folders in explorer view. if (attribs & (SFGAO_FOLDER|SFGAO_HASSUBFOLDER)) pw32fdata->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY; @@ -240,15 +240,17 @@ void ShellDirectory::read_directory() memset(&w32fd, 0, sizeof(WIN32_FIND_DATA)); - SFGAOF attribs_before = ~SFGAO_READONLY&~SFGAO_VALIDATE; + SFGAOF attribs_before = ~SFGAO_READONLY & ~SFGAO_VALIDATE; SFGAOF attribs = attribs_before; HRESULT hr = _folder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidls[n], &attribs); + bool removeable = false; if (SUCCEEDED(hr) && attribs!=attribs_before) { // avoid accessing floppy drives when browsing "My Computer" - if (attribs & SFGAO_REMOVABLE) + if (attribs & SFGAO_REMOVABLE) { attribs |= SFGAO_HASSUBFOLDER; - else { + removeable = true; + } else { DWORD attribs2 = SFGAO_READONLY; HRESULT hr = _folder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidls[n], &attribs2); @@ -259,7 +261,7 @@ void ShellDirectory::read_directory() } else attribs = 0; - bhfi_valid = fill_w32fdata_shell(pidls[n], attribs, &w32fd, &bhfi, !(attribs&SFGAO_REMOVABLE)); + bhfi_valid = fill_w32fdata_shell(pidls[n], attribs, &w32fd, &bhfi, !removeable); Entry* entry; diff --git a/reactos/subsys/system/explorer/shell/shellfs.h b/reactos/subsys/system/explorer/shell/shellfs.h index 36e2e323c9d..f4e31a672ed 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.h +++ b/reactos/subsys/system/explorer/shell/shellfs.h @@ -103,7 +103,7 @@ struct ShellDirectory : public ShellEntry, public Directory HWND _hwnd; protected: - bool fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA*, BY_HANDLE_FILE_INFORMATION*, bool access=true); + bool fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA*, BY_HANDLE_FILE_INFORMATION*, bool do_access=true); }; diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.h b/reactos/subsys/system/explorer/taskbar/desktopbar.h index 131ad5ca5b7..d5c48c50760 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.h +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.h @@ -26,11 +26,11 @@ // -#define CLASSNAME_EXPLORERBAR _T("Shell_TrayWnd") -#define TITLE_EXPLORERBAR _T("") // use an empty window title, so windows taskmanager does not show the window in its application list +#define CLASSNAME_EXPLORERBAR TEXT("Shell_TrayWnd") +#define TITLE_EXPLORERBAR TEXT("") // use an empty window title, so windows taskmanager does not show the window in its application list -#define WINMSG_TASKBARCREATED _T("TaskbarCreated") +#define WINMSG_TASKBARCREATED TEXT("TaskbarCreated") #define DESKTOPBARBAR_HEIGHT 29 diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp index 51fffb0c910..32b03812319 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp @@ -92,7 +92,7 @@ void QuickLaunchBar::AddShortcuts() SpecialFolderFSPath app_data(CSIDL_APPDATA, _hwnd); - _stprintf(path, _T("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data); + _stprintf(path, TEXT("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data); _dir = new ShellDirectory(Desktop(), path, _hwnd); diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.h b/reactos/subsys/system/explorer/taskbar/quicklaunch.h index cf7255fa8dd..e2983104f4c 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.h +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.h @@ -35,7 +35,7 @@ #define IDC_FIRST_QUICK_ID 0x4000 -#define QUICKLAUNCH_FOLDER _T("Microsoft\\Internet Explorer\\Quick Launch") +#define QUICKLAUNCH_FOLDER TEXT("Microsoft\\Internet Explorer\\Quick Launch") /// quick launch bar shortcut diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index c1846400527..5dd42a8c189 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -803,7 +803,7 @@ void StartMenuRoot::ShowLaunchDialog(HWND hwndDesktopBar) static LPCSTR szTitle = "Create New Task"; static LPCSTR szText = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you."; - static DynamicFct RunFileDlg(_T("SHELL32"), 61); + static DynamicFct RunFileDlg(TEXT("SHELL32"), 61); // Show "Run..." dialog if (RunFileDlg) { @@ -823,7 +823,7 @@ void StartMenuRoot::ShowLaunchDialog(HWND hwndDesktopBar) void StartMenuRoot::ShowExitWindowsDialog(HWND hwndOwner) { - static DynamicFct ExitWindowsDlg(_T("SHELL32"), 60); + static DynamicFct ExitWindowsDlg(TEXT("SHELL32"), 60); if (ExitWindowsDlg) (*ExitWindowsDlg)(hwndOwner); @@ -831,7 +831,7 @@ void StartMenuRoot::ShowExitWindowsDialog(HWND hwndOwner) void StartMenuRoot::ShowRestartDialog(HWND hwndOwner, UINT flags) { - static DynamicFct RestartDlg(_T("SHELL32"), 59); + static DynamicFct RestartDlg(TEXT("SHELL32"), 59); if (RestartDlg) (*RestartDlg)(hwndOwner, (LPWSTR)L"You selected .\n\n", flags); //TODO: ANSI string conversion if needed @@ -839,7 +839,7 @@ void StartMenuRoot::ShowRestartDialog(HWND hwndOwner, UINT flags) void StartMenuRoot::ShowSearchDialog() { - static DynamicFct SHFindFiles(_T("SHELL32"), 90); + static DynamicFct SHFindFiles(TEXT("SHELL32"), 90); if (SHFindFiles) (*SHFindFiles)(NULL, NULL); @@ -847,7 +847,7 @@ void StartMenuRoot::ShowSearchDialog() void StartMenuRoot::ShowSearchComputer() { - static DynamicFct SHFindComputer(_T("SHELL32"), 91); + static DynamicFct SHFindComputer(TEXT("SHELL32"), 91); if (SHFindComputer) (*SHFindComputer)(NULL, NULL); @@ -878,7 +878,7 @@ int SettingsMenu::Command(int id, int code) case IDC_CONTROL_PANEL: CloseStartMenu(id); - MainFrame::Create(_T("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"), FALSE); + MainFrame::Create(TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"), FALSE); break; case IDC_ADMIN: diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index dd194adc0d5..745d142284c 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -26,8 +26,8 @@ // -#define CLASSNAME_STARTMENU _T("ReactosStartmenuClass") -#define TITLE_STARTMENU _T("Start Menu") +#define CLASSNAME_STARTMENU TEXT("ReactosStartmenuClass") +#define TITLE_STARTMENU TEXT("Start Menu") #define STARTMENU_WIDTH_MIN 120 diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.h b/reactos/subsys/system/explorer/taskbar/taskbar.h index 4b5029152cd..d630e44423b 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.h +++ b/reactos/subsys/system/explorer/taskbar/taskbar.h @@ -29,8 +29,8 @@ //#include "shellhook.h" -#define CLASSNAME_TASKBAR _T("MSTaskSwWClass") -#define TITLE_TASKBAR _T("Running Applications") +#define CLASSNAME_TASKBAR TEXT("MSTaskSwWClass") +#define TITLE_TASKBAR TEXT("Running Applications") #define IDC_FIRST_APP 0x2000 diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index ef3fe709ad0..777c64bbbc9 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -283,7 +283,7 @@ ClockWindow::ClockWindow(HWND hwnd) : super(hwnd), _tooltip(hwnd) { - *_time = _T('\0'); + *_time = TEXT('\0'); FormatTime(); _tooltip.add(_hwnd, _hwnd); @@ -306,9 +306,9 @@ LRESULT ClockWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) break; case WM_LBUTTONDBLCLK: - //launch_file(_hwnd, _T("timedate.cpl"), SW_SHOWNORMAL); // This would be enough, but we want the fastest solution. - //launch_file(_hwnd, _T("rundll32.exe /d shell32.dll,Control_RunDLL timedate.cpl"), SW_SHOWNORMAL); - RunDLL(_hwnd, _T("shell32"), "Control_RunDLL", _T("timedate.cpl"), SW_SHOWNORMAL); + //launch_file(_hwnd, TEXT("timedate.cpl"), SW_SHOWNORMAL); // This would be enough, but we want the fastest solution. + //launch_file(_hwnd, TEXT("rundll32.exe /d shell32.dll,Control_RunDLL timedate.cpl"), SW_SHOWNORMAL); + RunDLL(_hwnd, TEXT("shell32"), "Control_RunDLL", TEXT("timedate.cpl"), SW_SHOWNORMAL); break; default: diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.h b/reactos/subsys/system/explorer/taskbar/traynotify.h index db318f2be5e..a78ae4fb616 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.h +++ b/reactos/subsys/system/explorer/taskbar/traynotify.h @@ -26,10 +26,10 @@ // -#define CLASSNAME_TRAYNOTIFY _T("TrayNotifyWnd") -#define TITLE_TRAYNOTIFY _T("") +#define CLASSNAME_TRAYNOTIFY TEXT("TrayNotifyWnd") +#define TITLE_TRAYNOTIFY TEXT("") -#define CLASSNAME_CLOCKWINDOW _T("TrayClockWClass") +#define CLASSNAME_CLOCKWINDOW TEXT("TrayClockWClass") #define NOTIFYAREA_WIDTH 244 #define CLOCKWINDOW_WIDTH 32 diff --git a/reactos/subsys/system/explorer/utility/shellclasses.cpp b/reactos/subsys/system/explorer/utility/shellclasses.cpp index 372e8aa5c0d..44715793c81 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.cpp +++ b/reactos/subsys/system/explorer/utility/shellclasses.cpp @@ -268,7 +268,7 @@ String ShellFolder::get_name(LPCITEMIDLIST pidl, SHGDNF flags) const strret.GetString(pidl->mkid, buffer, MAX_PATH); else { CheckError(hr); - *buffer = _T('\0'); + *buffer = TEXT('\0'); } return buffer; @@ -337,7 +337,7 @@ ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl) const ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl) const { - static DynamicFct ILCombine(_T("SHELL32"), 25); + static DynamicFct ILCombine(TEXT("SHELL32"), 25); if (ILCombine) return (*ILCombine)(parent_pidl, _p); diff --git a/reactos/subsys/system/explorer/utility/shellclasses.h b/reactos/subsys/system/explorer/utility/shellclasses.h index b543e7cd262..2a1ff205039 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.h +++ b/reactos/subsys/system/explorer/utility/shellclasses.h @@ -77,7 +77,7 @@ struct COMException LocalFree(pBuf); } else { TCHAR buffer[128]; - _stprintf(buffer, _T("unknown COM Exception: 0x%08X"), _hr); + _stprintf(buffer, TEXT("unknown COM Exception: 0x%08X"), _hr); _msg = buffer; } } @@ -426,6 +426,13 @@ extern HRESULT name_from_pidl(IShellFolder* folder, LPCITEMIDLIST pidl, LPTSTR b #ifdef __MINGW32__ // ILGetSize() is currently missing in MinGW. extern "C" UINT ILGetSize(LPCITEMIDLIST pidl); + +#ifdef UNICODE // CFSTR_FILENAME is defined wrong in MinGW. +#define CFSTR_FILENAMEW TEXT("FileNameW") +#undef CFSTR_FILENAME +#define CFSTR_FILENAME CFSTR_FILENAMEW +#endif + #endif