|
-
Aug 1st, 2013, 12:40 PM
#1
Thread Starter
Hyperactive Member
How to find/move icons on desktop.
I'm writing an app for my own use, and I need to be able to detect if the app's icon is on the desktop. If it is, then I want to move it to a specific location on the desktop. I realize I'm probably going to be working with Interop services, here, but I can't find any reliable sources on how to accomplish what I wish to do. I'm developing this for a Windows 7 platform.
So, can anybody give me some idea how to do this?
-
Aug 1st, 2013, 02:25 PM
#2
Re: How to find/move icons on desktop.
If it is, then I want to move it to a specific location on the desktop.
Why? Any user can override this instantly and more than a few of us don't even allow desktop icons to spoil our perfect desktops anyway.
The effort necessary to get to the desktop 'window' and interact with it using SendMessage from the API, in the meantime making your application a crash waiting to happen, just isn't worth it for such a meaningless and temporary effect!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Aug 1st, 2013, 02:35 PM
#3
Thread Starter
Hyperactive Member
Re: How to find/move icons on desktop.
The app is one I'm writing for my home system to meet a need... I don't need a discussion on whether the utility I'm writing is needed or will be useful, I just need a guide on how to get this done. I'm willing to put in the work on the code... Technically it is possible, and that's what I need to know.
-
Aug 1st, 2013, 03:05 PM
#4
Re: How to find/move icons on desktop.
In theory it is possible, yes. You will need to use FindWindow and FindWindowEx (see pinvoke.com) to find your way to the desktop window which is a listview. You will then need to manipulate the listview using SendMessage. The appropriate messages are listed on MSDN (but without values so you'll be spending many a long hour trying to work that out!) You will also need to determine how effectively to marshal the listview structures required for many of the messages and having no little experience of attempting that I was merely warning you that that is where all the frustration which will almost certainly lead to you abandoning this (hopefully with your computer undamaged by multiple crashes) will be. But if you want to go ahead and ignore the 'Here be dragons!' signs and the parched skulls of those who have gone before you and failed then by all means be my guest. I'll even give you the first steps for free ....
vb.net Code:
Dim Hdesk As IntPtr = FindWindow("Progman", "Program Manager")
Dim hdesk1 = FindWindowEx(Hdesk, IntPtr.Zero, "SHELLDLL_DefView", vbNullString)
Dim hdesk2 = FindWindowEx(hdesk1, IntPtr.Zero, "SysListView32", "FolderView")
' hdesk2 is the handle for the listview where desktop icons are stored which you need for SendMessage
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|