INT ProcessStartupItems(VOID) { /* TODO: ProcessRunKeys already checks SM_CLEANBOOT -- items prefixed with * should probably run even in safe mode */ BOOL bNormalBoot = GetSystemMetrics(SM_CLEANBOOT) == 0; /* Perform the operations that are performed every boot */ /* First, set the current directory to SystemRoot */ WCHAR gen_path[MAX_PATH]; DWORD res; res = GetWindowsDirectoryW(gen_path, _countof(gen_path)); if (res == 0) { TRACE("Couldn't get the windows directory - error %lu\n", GetLastError()); return 100; } if (!SetCurrentDirectoryW(gen_path)) { TRACE("Cannot set the dir to %ls (%lu)\n", gen_path, GetLastError()); return 100; } /* Perform the operations by order checking if policy allows it, checking if this is not Safe Mode, * stopping if one fails, skipping if necessary. */ res = TRUE; /* TODO: RunOnceEx */ if (res && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0)) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE); if (res && bNormalBoot && (SHRestricted(REST_NOLOCALMACHINERUN) == 0)) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE); if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0)) res = ProcessRunKeys(HKEY_CURRENT_USER, L"Run", FALSE, FALSE); /* All users Startup folder */ AutoStartupApplications(CSIDL_COMMON_STARTUP); /* Current user Startup folder */ AutoStartupApplications(CSIDL_STARTUP); /* TODO: HKCU\RunOnce runs even if StartupHasBeenRun exists */ if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0)) res = ProcessRunKeys(HKEY_CURRENT_USER, L"RunOnce", TRUE, FALSE); TRACE("Operation done\n"); return res ? 0 : 101; }
void NotifyArea::read_config() { bool clock_visible = true; // read notification icon settings from XML configuration XMLPos cfg_pos = g_Globals.get_cfg(); #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_HIDECLOCK)) #endif { if (cfg_pos.go_down("desktopbar")) { clock_visible = XMLBoolRef(XMLPos(cfg_pos,"options"), "show-clock", !get_hide_clock_from_registry()); cfg_pos.back(); } } if (cfg_pos.go_down("notify-icons")) { XMLPos options(cfg_pos, "options"); _hide_inactive = XMLBool(options, "hide-inactive", true); ///@todo read default setting from registry _show_hidden = XMLBool(options, "show-hidden", false); ///@todo read default setting from registry _show_button = XMLBool(options, "show-button", true); XMLChildrenFilter icons(cfg_pos, "icon"); for(XMLChildrenFilter::iterator it=icons.begin(); it!=icons.end(); ++it) { const XMLNode& node = **it; NotifyIconConfig cfg; cfg._name = node.get("name").c_str(); cfg._tipText = node.get("text").c_str(); cfg._windowTitle = node.get("window").c_str(); cfg._modulePath = node.get("module").c_str(); const string& mode = node.get("show"); if (mode == "show") cfg._mode = NIM_SHOW; else if (mode == "hide") cfg._mode = NIM_HIDE; else //if (mode == "auto") cfg._mode = NIM_HIDE; _cfg.push_back(cfg); } cfg_pos.back(); } show_clock(clock_visible); }
virtual HRESULT STDMETHODCALLTYPE AppendMenu( OUT HMENU* phMenu) { HMENU hMenu, hSettingsMenu; DWORD dwLogoff; BOOL bWantLogoff; UINT uLastItemsCount = 5; /* 5 menu items below the last separator */ WCHAR szUser[128]; TRACE("ITrayPriv::AppendMenu\n"); hMenu = LoadPopupMenu(hExplorerInstance, MAKEINTRESOURCE(IDM_STARTMENU)); *phMenu = hMenu; if (hMenu == NULL) return E_FAIL; /* Remove menu items that don't apply */ dwLogoff = SHRestricted(REST_STARTMENULOGOFF); bWantLogoff = (dwLogoff == 2 || SHRestricted(REST_FORCESTARTMENULOGOFF) || GetExplorerRegValueSet(HKEY_CURRENT_USER, TEXT("Advanced"), TEXT("StartMenuLogoff"))); /* Favorites */ if (!GetExplorerRegValueSet(HKEY_CURRENT_USER, TEXT("Advanced"), TEXT("StartMenuFavorites"))) { DeleteMenu(hMenu, IDM_FAVORITES, MF_BYCOMMAND); } /* Documents */ if (SHRestricted(REST_NORECENTDOCSMENU)) { DeleteMenu(hMenu, IDM_DOCUMENTS, MF_BYCOMMAND); } /* Settings */ hSettingsMenu = FindSubMenu(hMenu, IDM_SETTINGS, FALSE); if (hSettingsMenu != NULL) { if (SHRestricted(REST_NOSETFOLDERS)) { /* Control Panel */ if (SHRestricted(REST_NOCONTROLPANEL)) { DeleteMenu(hSettingsMenu, IDM_CONTROLPANEL, MF_BYCOMMAND); /* Delete the separator below it */ DeleteMenu(hSettingsMenu, 0, MF_BYPOSITION); } /* Network Connections */ if (SHRestricted(REST_NONETWORKCONNECTIONS)) { DeleteMenu(hSettingsMenu, IDM_NETWORKCONNECTIONS, MF_BYCOMMAND); } /* Printers and Faxes */ DeleteMenu(hSettingsMenu, IDM_PRINTERSANDFAXES, MF_BYCOMMAND); } /* Security */ if (GetSystemMetrics(SM_REMOTECONTROL) == 0 || SHRestricted(REST_NOSECURITY)) { DeleteMenu(hSettingsMenu, IDM_SECURITY, MF_BYCOMMAND); } if (GetMenuItemCount(hSettingsMenu) == 0) { DeleteMenu(hMenu, IDM_SETTINGS, MF_BYCOMMAND); } } /* Search */ /* FIXME: Enable after implementing */ /* if (SHRestricted(REST_NOFIND)) */ { DeleteMenu(hMenu, IDM_SEARCH, MF_BYCOMMAND); } /* FIXME: Help */ /* Run */ if (SHRestricted(REST_NORUN)) { DeleteMenu(hMenu, IDM_RUN, MF_BYCOMMAND); } /* Synchronize */ if (!ShowSynchronizeMenuItem()) { DeleteMenu(hMenu, IDM_SYNCHRONIZE, MF_BYCOMMAND); uLastItemsCount--; } /* Log off */ if (dwLogoff != 1 && bWantLogoff) { /* FIXME: We need a more sophisticated way to determine whether to show or hide it, it might be hidden in too many cases!!! */ /* Update Log Off menu item */ if (!GetCurrentLoggedOnUserName(szUser, sizeof(szUser) / sizeof(szUser[0]))) { szUser[0] = _T('\0'); } if (!FormatMenuString(hMenu, IDM_LOGOFF, MF_BYCOMMAND, szUser)) { /* We couldn't update the menu item, delete it... */ DeleteMenu(hMenu, IDM_LOGOFF, MF_BYCOMMAND); } } else { DeleteMenu(hMenu, IDM_LOGOFF, MF_BYCOMMAND); uLastItemsCount--; } /* Disconnect */ if (GetSystemMetrics(SM_REMOTECONTROL) == 0) { DeleteMenu(hMenu, IDM_DISCONNECT, MF_BYCOMMAND); uLastItemsCount--; } /* Undock computer */ if (!ShowUndockMenuItem()) { DeleteMenu(hMenu, IDM_UNDOCKCOMPUTER, MF_BYCOMMAND); uLastItemsCount--; } /* Shut down */ if (SHRestricted(REST_NOCLOSE)) { DeleteMenu(hMenu, IDM_SHUTDOWN, MF_BYCOMMAND); uLastItemsCount--; } if (uLastItemsCount == 0) { /* Remove the separator at the end of the menu */ DeleteMenu(hMenu, IDM_LASTSTARTMENU_SEPARATOR, MF_BYCOMMAND); } return S_OK; }
static HRESULT STDMETHODCALLTYPE ITrayBandSiteImpl_ProcessMessage(IN OUT ITrayBandSite *iface, IN HWND hWnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam, OUT LRESULT *plResult) { ITrayBandSiteImpl *This = ITrayBandSiteImpl_from_ITrayBandSite(iface); HRESULT hRet; ASSERT(This->hWndRebar != NULL); /* Custom task band behavior */ switch (uMsg) { case WM_NOTIFY: { const NMHDR *nmh = (const NMHDR *)lParam; if (nmh->hwndFrom == This->hWndRebar) { switch (nmh->code) { case NM_NCHITTEST: { LPNMMOUSE nmm = (LPNMMOUSE)lParam; if (nmm->dwHitInfo == RBHT_CLIENT || nmm->dwHitInfo == RBHT_NOWHERE || nmm->dwItemSpec == (DWORD_PTR)-1) { /* Make the rebar control appear transparent so the user can drag the tray window */ *plResult = HTTRANSPARENT; } return S_OK; } case RBN_MINMAX: /* Deny if an Administrator disabled this "feature" */ *plResult = (SHRestricted(REST_NOMOVINGBAND) != 0); return S_OK; } } //DbgPrint("ITrayBandSite::ProcessMessage: WM_NOTIFY for 0x%p, From: 0x%p, Code: NM_FIRST-%u...\n", hWnd, nmh->hwndFrom, NM_FIRST - nmh->code); break; } }; /* Forward to the shell's IWinEventHandler interface to get the default shell behavior! */ if (This->WindowEventHandler != NULL) { /*DbgPrint("Calling IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p) This->hWndRebar=0x%p\n", hWnd, uMsg, wParam, lParam, plResult, This->hWndRebar);*/ hRet = IWinEventHandler_OnWinEvent(This->WindowEventHandler, hWnd, uMsg, wParam, lParam, plResult); if (!SUCCEEDED(hRet)) { if (uMsg == WM_NOTIFY) { const NMHDR *nmh = (const NMHDR *)lParam; DbgPrint("ITrayBandSite->IWinEventHandler::ProcessMessage: WM_NOTIFY for 0x%p, From: 0x%p, Code: NM_FIRST-%u returned 0x%x\n", hWnd, nmh->hwndFrom, NM_FIRST - nmh->code, hRet); } else { DbgPrint("ITrayBandSite->IWinEventHandler::ProcessMessage(0x%p,0x%x,0x%p,0x%p,0x%p->0x%p) returned: 0x%x\n", hWnd, uMsg, wParam, lParam, plResult, *plResult, hRet); } } } else hRet = E_FAIL; return hRet; }
BOOL _ProcessAttach(HINSTANCE hDll) // 32-bit { BOOL fSuccess = TRUE; // _asm int 3; g_hinst = hDll; g_hProcessHeap = GetProcessHeap(); #ifdef WINNT // // NT has no shared critical sections // InitializeCriticalSection(&g_csShell); InitializeCriticalSection(&g_csPrinters); #else // // This must be called for each attaching process otherwise // when the first process terminates the cs will be reclaimed. // ReinitializeCriticalSection(&g_csPrinters); ReinitializeCriticalSection(&g_csShell); #endif // // Open the useful registry keys // RegOpenKey(HKEY_CLASSES_ROOT, c_szCLSID, &g_hkcrCLSID); RegCreateKey(HKEY_CURRENT_USER, c_szRegExplorer, &g_hkcuExplorer); RegCreateKey(HKEY_LOCAL_MACHINE, c_szRegExplorer, &g_hklmExplorer); #ifdef WINNT if (0 != SHRestricted(REST_ENFORCESHELLEXTSECURITY)) RegOpenKey(HKEY_LOCAL_MACHINE, c_szApproved, &g_hklmApprovedExt); // Fetch the alternate color (for compression) if supplied. { DWORD cbData = sizeof(COLORREF); DWORD dwType; RegQueryValueEx(g_hkcuExplorer, c_szAltColor, NULL, &dwType, (LPBYTE)&g_crAltColor, &cbData); } #endif ENTERCRITICAL; if (g_cProcesses == 0) { fSuccess = _Initialize_SharedData(); } g_cProcesses++; LEAVECRITICAL; DebugMsg(DM_TRACE, TEXT("shell32: ProcessAttach: %s %d (%x)"), GetCurrentApp(), g_cProcesses, hDll); #ifdef DEBUG #define DEREFMACRO(x) x #define ValidateORD(_name) Assert( _name == (LPVOID)GetProcAddress(hDll, (LPSTR)MAKEINTRESOURCE(DEREFMACRO(_name##ORD))) ) if (g_cProcesses==1) // no need to be in critical section (just debug) { ValidateORD(SHValidateUNC); ValidateORD(SHChangeNotifyRegister); ValidateORD(SHChangeNotifyDeregister); ValidateORD(OleStrToStrN); ValidateORD(SHCloneSpecialIDList); Assert(DllGetClassObject==(LPVOID)GetProcAddress(hDll,(LPSTR)MAKEINTRESOURCE(SHDllGetClassObjectORD))); ValidateORD(SHLogILFromFSIL); ValidateORD(SHMapPIDLToSystemImageListIndex); ValidateORD(SHShellFolderView_Message); ValidateORD(Shell_GetImageLists); ValidateORD(SHGetSpecialFolderPath); ValidateORD(StrToOleStrN); ValidateORD(ILClone); ValidateORD(ILCloneFirst); ValidateORD(ILCombine); ValidateORD(ILCreateFromPath); ValidateORD(ILFindChild); ValidateORD(ILFree); ValidateORD(ILGetNext); ValidateORD(ILGetSize); ValidateORD(ILIsEqual); ValidateORD(ILRemoveLastID); ValidateORD(PathAddBackslash); ValidateORD(PathCombine); ValidateORD(PathIsExe); ValidateORD(PathMatchSpec); ValidateORD(SHGetSetSettings); ValidateORD(SHILCreateFromPath); ValidateORD(SHFree); ValidateORD(SHAddFromPropSheetExtArray); ValidateORD(SHCreatePropSheetExtArray); ValidateORD(SHDestroyPropSheetExtArray); ValidateORD(SHReplaceFromPropSheetExtArray); ValidateORD(SHCreateDefClassObject); ValidateORD(SHGetNetResource); } #ifdef WINNT /* * read wDebugMask entry from win.ini for SHELL32.DLL. * The default is 0x000E, which includes DM_WARNING, DM_ERROR, * and DM_ASSERT. The default has DM_TRACE and DM_ALLOC turned * off. */ { CHAR szDebugMask[ 80 ]; if (GetProfileStringA( "Shell32", "DebugMask", "0x000E", szDebugMask, ARRAYSIZE(szDebugMask)) > 0 ) { sscanf( szDebugMask, "%i", &wDebugMask ); } } #endif // WINNT #endif // // All the per-instance initialization code should come here. // // // This block must be placed at the end of this function. // #ifdef DEBUG { extern LPMALLOC g_pmemTask; if (g_pmemTask) { MessageBeep(0); DebugMsg(DM_ERROR, TEXT("sh TR - Somebody called SHAlloc in LibMain!")); Assert(0); } } #endif return fSuccess; }