Skip to content

Commit

Permalink
Start10: Implemented proper fix for Pin to Start/Unpin from Start
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Oct 5, 2023
1 parent a4f5bd0 commit 15c07a0
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 234 deletions.
120 changes: 0 additions & 120 deletions ExplorerPatcher/GUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,126 +2239,6 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
}
}
}
else if (!strncmp(line + 1, "pin_tiles", 9))
{
BOOL bFirst = TRUE;
DWORD dwPermitOldStartTileData = TRUE;
DWORD dwSize = sizeof(DWORD);
RegSetKeyValueW(HKEY_CURRENT_USER, L"Software\\ExplorerPatcher", L"PermitOldStartTileDataOneShot", REG_DWORD, &dwPermitOldStartTileData, dwSize);
/*
LPCWSTR csPath = L"::{26EE0668-A00A-44D7-9371-BEB064C98683}";
SFGAOF stSFGAOFIn = 0;
SFGAOF stSFGAOFOut = 0;
SHParseDisplayName(csPath, NULL, &pidl, stSFGAOFIn, &stSFGAOFOut);
*/
WCHAR wszOrigPath[MAX_PATH], wszCurPath[MAX_PATH];
IShellFolder* psfDesktop = NULL;
hr = SHGetDesktopFolder(&psfDesktop);
if (psfDesktop)
{
LPITEMIDLIST pidl;
hr = SHGetFolderLocation(NULL, CSIDL_CONTROLS, (HANDLE)-1, 0, &pidl);
if (pidl)
{
STRRET strret;
hr = psfDesktop->lpVtbl->GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret);
StrRetToBufW(&strret, pidl, wszOrigPath, MAX_PATH);
SHOpenFolderAndSelectItems(pidl, 0, NULL, 0);
VARIANT vt;
HRESULT hr = E_FAIL;
IShellWindows* pShellWindows = NULL;
hr = CoCreateInstance(&CLSID_ShellWindows, NULL, CLSCTX_ALL, &IID_IShellWindows, &pShellWindows);
if (pShellWindows)
{
long k = 0;
pShellWindows->lpVtbl->get_Count(pShellWindows, &k);
for (int i = 0; i < k; ++i)
{
vt.vt = VT_I4;
vt.intVal = i;
IDispatch* pDispatch = NULL;
hr = pShellWindows->lpVtbl->Item(pShellWindows, vt, &pDispatch);
if (pDispatch)
{
IWebBrowserApp* pWebBrowserApp = NULL;
hr = pDispatch->lpVtbl->QueryInterface(pDispatch, &IID_IWebBrowserApp, &pWebBrowserApp);
if (pWebBrowserApp)
{
IServiceProvider* pServiceProvider = NULL;
hr = pWebBrowserApp->lpVtbl->QueryInterface(pWebBrowserApp, &IID_IServiceProvider, &pServiceProvider);
if (pServiceProvider)
{
IShellBrowser* pShellBrowser = NULL;
hr = pServiceProvider->lpVtbl->QueryService(pServiceProvider, &SID_STopLevelBrowser, &IID_IShellBrowser, &pShellBrowser);
if (pShellBrowser)
{
IShellView* pShellView = NULL;
hr = pShellBrowser->lpVtbl->QueryActiveShellView(pShellBrowser, &pShellView);
if (pShellView)
{
IFolderView* pFolderView = NULL;
hr = pShellView->lpVtbl->QueryInterface(pShellView, &IID_IFolderView, &pFolderView);
if (pFolderView)
{
IPersistFolder2* pPersistFolder2 = NULL;
hr = pFolderView->lpVtbl->GetFolder(pFolderView, &IID_IPersistFolder2, &pPersistFolder2);
if (pPersistFolder2)
{
LPITEMIDLIST pCur = NULL;
hr = pPersistFolder2->lpVtbl->GetCurFolder(pPersistFolder2, &pCur);
if (pCur)
{
hr = psfDesktop->lpVtbl->GetDisplayNameOf(psfDesktop, pCur, SHGDN_FORPARSING, &strret);
StrRetToBufW(&strret, pidl, wszCurPath, MAX_PATH);
if (!_wcsnicmp(wszOrigPath, wszCurPath, 40) && wcslen(wszCurPath) == 40 && bFirst)
{
LPITEMIDLIST pNew = NULL;
hr = SHGetFolderLocation(NULL, CSIDL_DRIVES, (HANDLE)-1, 0, &pNew);
if (pNew)
{
hr = pShellBrowser->lpVtbl->BrowseObject(pShellBrowser, pNew, SBSP_SAMEBROWSER);
if (SUCCEEDED(hr))
{
HWND hWndExp = NULL;
pWebBrowserApp->lpVtbl->get_HWND(pWebBrowserApp, &hWndExp);
if (hWndExp)
{
INPUT input;
ZeroMemory(&input, sizeof(INPUT));
input.type = INPUT_KEYBOARD;
input.ki.wVk = VK_F5;
SetForegroundWindow(hWndExp);
SendInput(1, &input, sizeof(INPUT));
bFirst = FALSE;
}
}
CoTaskMemFree(pNew);
}
}
CoTaskMemFree(pCur);
}
pPersistFolder2->lpVtbl->Release(pPersistFolder2);
}
pFolderView->lpVtbl->Release(pFolderView);
}
pShellView->lpVtbl->Release(pShellView);
}
pShellBrowser->lpVtbl->Release(pShellBrowser);
}
pServiceProvider->lpVtbl->Release(pServiceProvider);
}
pWebBrowserApp->lpVtbl->Release(pWebBrowserApp);
}
pDispatch->lpVtbl->Release(pDispatch);
}
}
pShellWindows->lpVtbl->Release(pShellWindows);
}
CoTaskMemFree(pidl);
}
psfDesktop->lpVtbl->Release(psfDesktop);
}
}
else if (!strncmp(line + 1, "spotlight_menu", 14))
{
POINT p;
Expand Down
2 changes: 0 additions & 2 deletions ExplorerPatcher/GUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include "utility.h"
#include "../ep_weather_host/ep_weather.h"
#include "../ep_weather_host/ep_weather_host_h.h"
#include <ExDisp.h>
#include <ShlGuid.h>

#define MAX_LINE_LENGTH 2000
extern HMODULE hModule;
Expand Down
Loading

4 comments on commit 15c07a0

@valinet
Copy link
Owner

@valinet valinet commented on 15c07a0 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amrsatrio settings.reg should be patched as well, taking out the lines that draw that "Pin to Start..." link.

@Amrsatrio
Copy link
Collaborator Author

@Amrsatrio Amrsatrio commented on 15c07a0 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the MUST READ? I also don't want to annoy fork maintainers who have translated texts 😅

@valinet
Copy link
Owner

@valinet valinet commented on 15c07a0 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amrsatrio settings.reg should be patched as well, taking out the lines that draw that "Pin to Start..." link.

Disregard this, I missed the part where you actually did this, my bad, sorry.

Should we keep the MUST READ?

Maybe tone it down, something like Learn more about the Windows 10 Start menu 🡕?

I also don't want to annoy fork maintainers who have translated texts

That's one of the reasons I never went down the route of supporting translations. Not to mention, the whole Properties UI is more of a hack, more of a show off, of a "it can be done this way if you insist", but not the best example for picking up a robust technology, that allows easy maintenance, extensibility, scalability etc. My wild C days...

@valinet
Copy link
Owner

@valinet valinet commented on 15c07a0 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, if a string needs to be modified, so be it - their translation wouldn't break actually, as the parser would still parse and interpret correctly their file and display it, it's only when you remove the functionality that it linked to (for example, the code for "Pin tiles" is now removed, so even if you still display that in the UI, it does nothing. But yeah, we cannot freeze the UI forever because there are translations out there. Plus, changes here are kind of rare and in between, so I do not think it's that big of a deal.

Please sign in to comment.