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