Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to get DesktopView to access and move desktop icons #400

Open
KWB opened this issue Feb 13, 2024 · 0 comments
Open

Question: How to get DesktopView to access and move desktop icons #400

KWB opened this issue Feb 13, 2024 · 0 comments

Comments

@KWB
Copy link

KWB commented Feb 13, 2024

Version of SharpShell used: 2.7.2

R.Chan shows how to do it in C++. I try to do it in C#. How can I access the Desktop View to manipulate the icons. I can get the Desktop folder, but how would I get the desktop view.

https://devblogs.microsoft.com/oldnewthing/20130318-00/?p=4933

So basically I wonder how I can port this to C#. Any hint?
Related SO question: https://stackoverflow.com/q/77958389/356726

void FindDesktopFolderView(REFIID riid, void **ppv)
{
 CComPtr<IShellWindows> spShellWindows;
 spShellWindows.CoCreateInstance(CLSID_ShellWindows);

 CComVariant vtLoc(CSIDL_DESKTOP);
 CComVariant vtEmpty;
 long lhwnd;
 CComPtr<IDispatch> spdisp;
 spShellWindows->FindWindowSW(
     &vtLoc, &vtEmpty,
     SWC_DESKTOP, &lhwnd, SWFO_NEEDDISPATCH, &spdisp);

 CComPtr<IShellBrowser> spBrowser;
 CComQIPtr<IServiceProvider>(spdisp)->
     QueryService(SID_STopLevelBrowser,
                  IID_PPV_ARGS(&spBrowser));

 CComPtr<IShellView> spView;
 spBrowser->QueryActiveShellView(&spView);

 spView->QueryInterface(riid, ppv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant