Jump to content
  • Advertisement
Sign in to follow this  
p0is0n

[C#] Setting Desktop Icon Position

This topic is 3125 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am trying to make a small C# application that allows you to save and restore the desktop shortcuts. From reading : http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/d7df8a4d-fc0f-4b62-80c9-7768756456e6 I have managed (with only slight alterations) to get the desktop icons positions and names. When I try to set an icons position I use :
                uint bytesRead = 0;
                long[] lParam = new long[1];
                lParam[0] = MakeLParam(200, 200);
                WriteProcessMemory(process, address, Marshal.UnsafeAddrOfPinnedArrayElement(lParam, 0),
                    Marshal.SizeOf(typeof(long)), ref bytesRead);
                SendMessage(desktop, LVM_SETITEMPOSITION, 0, address.ToInt32());
MakeLParam is defined as :
        public long MakeLParam(int loWord, int hiWord)
        {
            return (long)((hiWord << 16) | (loWord & 0xffff));
        }
process and address are both valid as are used in previous calls to get the icon information. No matter what position I define for the desktop icon the position is set to : X = 14 Y = 688 No functions fail and bytesRead is always 4. I am pretty sure the MakeLParam function is correct. Can anyone see where I might be going wrong? Thanks! [edit] I have changed the int return from MakeLParam and the lParam variable to longs as I think that is what they should be. The problem is still the same though. [edit] After playing around it seems that the set icon position message can be sent without writing anything to the desktop list view process. Still not sure what is wrong with the above code :S I am not sure if this is the right way to do it, but as it works I think I'll just leave it as it is. [Edited by - p0is0n on March 8, 2010 8:25:54 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!