简体   繁体   English

Windows XP,HKCU \\ ... \\ LastVisitedMRU允许的最大项目数?

[英]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". 值名称从字母表的开头开始,但我不想假设它们以“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. 经过许多痛苦的快照和文件/ Regmon会话之后,这似乎就是这样做的。 I know it's very hackish but it does work, I have tested the theory manually. 我知道它非常hackish但它确实有效,我已经手动测试了这个理论。 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. 也就是说,我肯定愿意接受有关如何以更加Win32友好的方式执行此操作的建议 - 假设应用程序没有更好的机制来执行此操作。

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. 对于每个可执行文件名,此注册表项包含该应用程序最后执行其SaveAs(可能是Save,我不确定)的目录。

Each letter holds information for one executable and the MRUList holds the order (this is important). 每个字母都包含一个可执行文件的信息,而MRUList保存订单(这很重要)。

Mine is maxed out at "y" and my MRUList is sxahmcjierfobglyuqpdtwvkn . 我的最大值是“y”,我的MRUListsxahmcjierfobglyuqpdtwvkn

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 . 从实验中,当我从已经存在的应用程序执行SaveAs时,它只是替换该字母的信息并将其移动到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 . 如果应用程序不存在且并非所有字母都在MRUList ,它会抓取第一个可用的字母,将信息放入该字母,然后将该字母放在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 . 如果应用程序不在那里并且使用了所有字母,它将抓取MRUList上的最后一个字母,将信息放入该字母,然后将其移动到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'. 我注意到为一个全新的应用程序做一个SaveAs并没有给我z字母,它重新使用了`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. 密钥本身看起来像UCS-2(16位Unicode,我的澳大利亚版Windows中带有散布空字节的ASCII,您的里程可能因国际变体而异)并且它们保存以空值终止的可执行文件名,然后是空终止的目录。

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). ComDlg32是Windows本身的常见对话框(Open,SaveAs,Print setup等)。

If you want to set the MRU for a given application, follow these steps. 如果要为给定的应用程序设置MRU,请按照下列步骤操作。

1/ Search for that application in the letter keys. 1 /在字母键中搜索该应用程序。 If you find it, go to step 3. 如果找到,请转到步骤3。

2/ Get the next letter available that's not in the MRUList . 2 /获取下一个不在MRUList中的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 . 如果MRUList已经包含所有字母ay 或者您不确定y将始终是最后一个(它可以在注册表中的其他位置配置),请抓取MRUList末尾的最后一个字母。

3/ Now you have your letter. 3 /现在你收到了你的来信。 Change or create that letter key with the UCS-2 data for your application and directory (both null-terminated). 使用应用程序和目录的UCS-2数据更改或创建该字母键(均以空值终止)。

4/ Change the MRUList to put your letter at the front. 4 /更改MRUList以将您的信件放在前面。

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.) (我也会尝试使用任何角色,但运气好但可能有用。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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