Windows triggers desktop icon layout save

Source: Internet
Author: User

Problem:

The original structure of the project was introduced into a disk suite, similar to the Explorer.exe process of shutting down the system, into the Explorer.exe he maintained. As a result, when you exit the disk without saving the desktop layout information, the next time you enter the disk, the desktop information becomes the state of initialization.

The problem here is that there is no mechanism to automatically save the desktop information, so the disk exits without saving the surface facts status information to the registry.

Resolution process:

Check the information that Windows will have desktop layout information under Registry \hkey_current_user\software\microsoft\windows\shell\bags\1\desktop, Each time Explorer.exe starts, it reads the registry to initialize the desktop layout information. There are several ways to trigger the saving of desktop layout information into this registry during the Explorer.exe run process. The simplest way to do this is to press F5 to refresh (and, of course, the right-click menu refreshes as well).

You can therefore consider simulating sending F5 messages to Explorer.exe to refresh the desktop, ensuring that the registry saves the fact that the desktop is on the table when the disk exits.

However, to note that the implementation of desktop refresh in the program to avoid the desktop flashing, I am here by sending F5 before the desktop redraw, after the end of the way to restore, but because the WM_KEYDOWN message only through the post is valid, sent by send invalid, So if the redraw is still refreshed at once, try to sleep for a short period of time and find that the desktop does not blink. Basically meet the needs.

The code snippet is as follows:

//Desktop Window nameHWND Lhwndprogman =:: FindWindow (L"ProgMan", NULL);if(NULL = =Lhwndprogman) Break;::P ostmessage (Lhwndprogman, Wm_setredraw,0,0); HWND Lhwndlistview=:: FindWindowEx (FindWindowEx (Lhwndprogman, NULL, L"Shelldll_defview", null), NULL, L"SysListView32", NULL);::P ostmessage (Lhwndlistview, WM_KEYDOWN, Vk_f5,0); Sleep ( -);::P ostmessage (Lhwndprogman, Wm_setredraw,1,0);

Windows triggers desktop icon layout save

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.