From: http://blog.csdn.net/zxjl0214/archive/2008/10/10/3051928.aspx
One expert said that the recent Programs icon on the home interface can be removed as long as the registry key value is modified:
[HKEY_CURRENT_USER/system/State/Shell]
"Start MRU"
I tried it for a moment, and I can post it for a moment.
E.g. The Code is as follows:
Removerecentprograms (_ T ("// windows // Start Menu // messaging. lnk "));
- Bool removerecentprograms (tchar * szlnkpath)
- {
- Bool Bret = false;
- Hkey = NULL;
- Byte * pdata = NULL;
- Byte * pdatanew = NULL;
- Byte * pindex = NULL;
- DWORD dwtype;
- DWORD cbdata;
- Int ilnkcount = 0;
- Int icurlen = 0;
- If (error_success! = Regopenkeyex (HKEY_CURRENT_USER, _ T ("system // state // shell"), 0, 0, & hkey ))
- {
- Goto exit;
- }
- If (error_success! = Regqueryvalueex (hkey, _ T ("start mru"), null, & dwtype, null, & cbdata ))
- {
- Goto exit;
- }
- Pdata = new byte [cbdata];
- If (! Pdata)
- {
- Goto exit;
- }
- If (error_success! = Regqueryvalueex (hkey, _ T ("start mru"), null, & dwtype, pdata, & cbdata ))
- {
- Goto exit;
- }
- Ilnkcount = pdata [0];
- Pindex = pdata + 4;
- Icurlen = 4;
- For (INT I = 0; I <ilnkcount; I ++)
- {
- Int ilnklen = pindex [0];
- If (! _ Tcscmp (szlnkpath, (tchar *) (pindex + 12 )))
- {
- Pdatanew = new byte [cbdata-ilnklen];
- If (! Pdatanew)
- {
- Goto exit;
- }
- Memcpy (pdatanew, pdata, icurlen );
- If (icurlen + ilnklen <cbdata)
- {
- Memcpy (pdatanew + icurlen, pdata + icurlen + ilnklen, cbdata-icurlen-ilnklen );
- }
- Pdatanew [0] --;
- If (error_success! = Regsetvalueex (hkey, _ T ("start mru"), 0, dwtype, pdatanew, cbdata-ilnklen ))
- {
- Goto exit;
- }
- Bret = true;
- Break;
- }
- Pindex + = ilnklen;
- Icurlen + = ilnklen;
- }
- Exit:
- If (pdata)
- {
- Delete [] pdata;
- }
- (Pdatanew)
- {
- Delete [] pdatanew;
- }
- If (hkey)
- {
- Regclosekey (hkey );
- }
- Return Bret;
- }
ReferenceBearbrotherjiResearch results:
1. Start four bytes, such as 0a 00 00,
The first byte is the number of shortcuts recently used, that is, the number displayed on the main interface. This is usually 0 XA (10) after a period of use );
2. After the four bytes, all the shortcuts are used. We will illustrate only one of them, for example:
0x50, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x5c, 0x00, 0x57, 0x00,
0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00,
0x77, 0x00, 0x73, 0x00, 0x5c, 0x00, 0x53, 0x00,
0x74, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00,
0x20, 0x00, 0x4d, 0x00, 0x65, 0x00, 0x6e, 0x00,
0x75, 0x00, 0x5c, 0x00, 0x53, 0x00, 0x69, 0x00,
0x6d, 0x00, 0x54, 0x00, 0x6b, 0x00, 0x55, 0x00,
0x49, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x6e, 0x00,
0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Each shortcut starts with four bytes, followed by the "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff" of the eight bytes ", the first character of these four bytes will change, but I do not know the meaning of this character, but it does not affect the processing;
Then there is a string corresponding to the path and file name of the shortcut file,
At last, there must be a 4bytes data with a 4 bytes address alignment, indicating the end of this shortcut;
If you want to implement the function as you mentioned, delete a recently used shortcut icon from the main interface,
First, reduce the value of the first byte by 1,
Next, find the complete string corresponding to the shortcut you want to delete in the entire string, and delete the segment, while retaining the rest (remember not to delete the subsequent string as well, to be connected, write back );
My supplement:
Each shortcut starts with four bytes, which indicates the length of the lnk, including the four bytes starting with, "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff "the length of the eight bytes and the lnk string (including the filled 0x00 bytes ).