add some calls to SHRestricted to replace awfull Registry reading

svn path=/trunk/; revision=6458
This commit is contained in:
Martin Fuchs
2003-10-29 21:37:14 +00:00
parent 4a4b64e0e7
commit f2be62ff1a
6 changed files with 101 additions and 32 deletions
@@ -58,6 +58,9 @@ ExplorerGlobals::ExplorerGlobals()
_prescan_nodes = false;
_desktop_mode = false;
_log = NULL;
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
_SHRestricted = 0;
#endif
}
@@ -237,6 +240,9 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
#endif
g_Globals._hInstance = hInstance;
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
g_Globals._SHRestricted = (DWORD(STDAPICALLTYPE*)(RESTRICTIONS)) GetProcAddress(GetModuleHandle(TEXT("SHELL32")), "SHRestricted");
#endif
HWND hwndDesktop = 0;
+4
View File
@@ -38,6 +38,10 @@ extern struct ExplorerGlobals
bool _desktop_mode;
FILE* _log;
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
DWORD(STDAPICALLTYPE* _SHRestricted)(RESTRICTIONS);
#endif
} g_Globals;
#define LOG(x) if (g_Globals._log) _ftprintf(g_Globals._log, TEXT("%s\n"), (LPCTSTR)(x));
@@ -91,8 +91,11 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
// create task bar
_hwndTaskBar = TaskBar::Create(_hwnd);
// create tray notification area
_hwndNotify = NotifyArea::Create(_hwnd);
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NOTRAYITEMSDISPLAY))
#endif
// create tray notification area
_hwndNotify = NotifyArea::Create(_hwnd);
_hwndQuickLaunch = QuickLaunchBar::Create(_hwnd);
@@ -676,13 +676,16 @@ void StartMenuButton::DrawItem(LPDRAWITEMSTRUCT dis)
StartMenuRoot::StartMenuRoot(HWND hwnd)
: super(hwnd)
{
try {
// insert directory "All Users\Start Menu"
ShellDirectory cmn_startmenu(Desktop(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd);
_dirs.push_back(StartMenuDirectory(cmn_startmenu, false)); // don't add subfolders
} catch(COMException&) {
// ignore exception and don't show additional shortcuts
}
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NOCOMMONGROUPS))
#endif
try {
// insert directory "All Users\Start Menu"
ShellDirectory cmn_startmenu(Desktop(), SpecialFolderPath(CSIDL_COMMON_STARTMENU, _hwnd), _hwnd);
_dirs.push_back(StartMenuDirectory(cmn_startmenu, false)); // don't add subfolders
} catch(COMException&) {
// ignore exception and don't show additional shortcuts
}
try {
// insert directory "<user name>\Start Menu"
@@ -769,17 +772,23 @@ LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs)
AddSeparator();
HKEY hkey;
#ifdef __MINGW32__
HKEY hkey, hkeyAdv;
DWORD value, len;
if (RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"), &hkey))
hkey = 0;
#define IS_VALUE_ZERO(name) \
(!hkey || (len=sizeof(value),RegQueryValueEx(hkey, name, NULL, NULL, (LPBYTE)&value, &len) || !value))
if (RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), &hkeyAdv))
hkeyAdv = 0;
#define IS_VALUE_ZERO(hk, name) \
(!hk || (len=sizeof(value),RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE)&value, &len) || !value))
#define IS_VALUE_NOT_ZERO(hk, name) \
(!hk || (len=sizeof(value),RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE)&value, &len) || value>0))
#endif
#define IS_VALUE_NOT_ZERO(name) \
(!hkey || (len=sizeof(value),RegQueryValueEx(hkey, name, NULL, NULL, (LPBYTE)&value, &len) || value>0))
// insert hard coded start entries
AddButton(ResString(IDS_PROGRAMS), 0, true, IDC_PROGRAMS);
@@ -788,7 +797,11 @@ LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs)
AddButton(ResString(IDS_DOCUMENTS), 0, true, IDC_DOCUMENTS);
if (IS_VALUE_ZERO(_T("NoRecentDocsMenu")))
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NORECENTDOCSMENU))
#else
if (IS_VALUE_ZERO(hkey, _T("NoRecentDocsMenu")))
#endif
AddButton(ResString(IDS_RECENT), 0, true, IDC_RECENT);
AddButton(ResString(IDS_FAVORITES), 0, true, IDC_FAVORITES);
@@ -797,33 +810,51 @@ LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs)
AddButton(ResString(IDS_BROWSE), 0, true, IDC_BROWSE);
if (IS_VALUE_ZERO(_T("NoFind"))) {
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NOFIND))
#else
if (IS_VALUE_ZERO(hkey, _T("NoFind")))
#endif
AddButton(ResString(IDS_SEARCH), 0, false, IDC_SEARCH);
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_HASFINDCOMPUTERS))
#endif
AddButton(ResString(IDS_SEARCH_COMPUTER),0,false, IDC_SEARCH_COMPUTER);
}
AddButton(ResString(IDS_START_HELP), 0, false, IDC_START_HELP);
if (IS_VALUE_ZERO(_T("NoRun")))
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NORUN))
#else
if (IS_VALUE_ZERO(hkey, _T("NoRun")))
#endif
AddButton(ResString(IDS_LAUNCH), 0, false, IDC_LAUNCH);
AddSeparator();
if (IS_VALUE_ZERO(_T("NoClose")))
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NOCLOSE))
#else
if (IS_VALUE_NOT_ZERO(hkeyAdv, _T("StartMenuLogoff")))
#endif
AddButton(ResString(IDS_LOGOFF), SmallIcon(IDI_LOGOFF), false, IDC_LOGOFF);
RegCloseKey(hkey);
if (RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), &hkey))
hkey = 0;
if (IS_VALUE_NOT_ZERO(_T("StartMenuLogoff")))
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || SHRestricted(REST_STARTMENULOGOFF) != 1)
#else
if (IS_VALUE_ZERO(hkey, _T("NoClose")))
#endif
AddButton(ResString(IDS_SHUTDOWN), SmallIcon(IDI_LOGOFF), false, IDC_SHUTDOWN);
#ifdef __MINGW32__
RegCloseKey(hkeyAdv);
RegCloseKey(hkey);
#endif
return 0;
}
@@ -1014,11 +1045,19 @@ void SettingsMenu::AddEntries()
{
super::AddEntries();
AddButton(ResString(IDS_CONTROL_PANEL), 0, false, IDC_CONTROL_PANEL);
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NOCONTROLPANEL))
#endif
AddButton(ResString(IDS_CONTROL_PANEL), 0, false, IDC_CONTROL_PANEL);
AddButton(ResString(IDS_PRINTERS), 0, true, IDC_PRINTERS);
AddButton(ResString(IDS_CONNECTIONS), 0, true, IDC_CONNECTIONS);
AddButton(ResString(IDS_ADMIN), 0, true, IDC_ADMIN);
AddButton(ResString(IDS_SETTINGS_MENU), 0, true, IDC_SETTINGS_MENU);
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NOCONTROLPANEL))
#endif
AddButton(ResString(IDS_SETTINGS_MENU), 0, true, IDC_SETTINGS_MENU);
}
int SettingsMenu::Command(int id, int code)
@@ -1057,7 +1096,11 @@ void BrowseMenu::AddEntries()
{
super::AddEntries();
AddButton(ResString(IDS_NETWORK), 0, true, IDC_NETWORK);
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_NONETHOOD)) // or REST_NOENTIRENETWORK ?
#endif
AddButton(ResString(IDS_NETWORK), 0, true, IDC_NETWORK);
AddButton(ResString(IDS_DRIVES), 0, true, IDC_DRIVES);
}
@@ -168,7 +168,15 @@ int TaskBar::Notify(int id, NMHDR* pnmh)
//TaskBarEntry& entry = it->second;
ActivateApp(it, false);
ShowAppSystemMenu(it);
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
static DynamicFct<DWORD(STDAPICALLTYPE*)(RESTRICTIONS)> pSHRestricted(TEXT("SHELL32"), "SHRestricted");
#endif
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!(*pSHRestricted)(REST_NOTRAYCONTEXTMENU))
#endif
ShowAppSystemMenu(it);
}
break;}
@@ -92,10 +92,15 @@ LRESULT NotifyArea::Init(LPCREATESTRUCT pcs)
if (super::Init(pcs))
return 1;
// create clock window
_hwndClock = ClockWindow::Create(_hwnd);
#ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
if (!g_Globals._SHRestricted || !SHRestricted(REST_HIDECLOCK))
#endif
{
// create clock window
_hwndClock = ClockWindow::Create(_hwnd);
SetTimer(_hwnd, 0, 1000, NULL);
SetTimer(_hwnd, 0, 1000, NULL);
}
return 0;
}