简体   繁体   中英

Windows XP, HKCU\…\LastVisitedMRU maximum number of items allowed?

I have a scenario where I need to put together a script to add an entry to the following registry key for the current user:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU\

I am trying to find out the maximum number of values allowed in this key so that I can have my script tack another one onto the end. The value names start at the beginning of the alphabet but I don't want to assume that they end at "Z".

Background: We are re-packaging a proprietary (ie not our own, we don't have access to the source) application and trying to set its default File -> Open location. After many painful snapshotting and File/Regmon sessions this seems to be the way to do it. I know it's very hackish but it does work, I have tested the theory manually. That said, I am most certainly open to suggestions around how to do this in a more Win32-friendly way - under the assumption that the application doesn't have a nicer mechanism of its own to do this.

This registry key holds, for each executable name, the directory that that application last did its SaveAs (and maybe Save, I'm not sure) in.

Each letter holds information for one executable and the MRUList holds the order (this is important).

Mine is maxed out at "y" and my MRUList is sxahmcjierfobglyuqpdtwvkn .

From experimentation, when I do a SaveAs from an application that's already there, it just replaces the information for that letter and moves it to the front of the MRUList .

If the application isn't there and not all the letters are in the MRUList , it grabs the first available letter, places the information into that letter, then puts that letter at the front of the MRUList .

If the application isn't there and all the letters are used, it grabs the last one on the MRUList , places the information into that letter, then moves it to the front of the MRUList .

I note that doing a SaveAs for a brand new application doesn't give me the z letter, it re-uses the last one in the `MRUList'.

The keys themselves just look like UCS-2 (16-bit Unicode, ASCII with interspersed null bytes in my Australia version of Windows, your mileage may vary for international variants) and they hold the null-terminated executable name, then the null-terminated directory.

And regarding your comment about not having access to the source of that application, it doesn't matter. It's not that application changing those keys. ComDlg32 is the common dialogs of Windows itself (Open, SaveAs, Print setup, etc).

If you want to set the MRU for a given application, follow these steps.

1/ Search for that application in the letter keys. If you find it, go to step 3.

2/ Get the next letter available that's not in the MRUList . If the MRUList already has all the letters a through y or you're not confident that y will always be the last one (it may be configurable somewhere else in the registry), grab the last letter that is at the end of the MRUList .

3/ Now you have your letter. Change or create that letter key with the UCS-2 data for your application and directory (both null-terminated).

4/ Change the MRUList to put your letter at the front.

There. That should do it.

除非我误解你的情况,否则标准的Windows OpenFileDialog应该有一个名为InitialDirectory的属性,它指定对话框应该打开的目录。

Are the other ones important? I would consider dropping the others, or re-using the first or last one. (I would also have a try using just any character, with a but of luck it may work.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM