Windows XP、HKCU\...\LastVisitedMRU 允许的最大项目数?
我有一个场景,我需要编写一个脚本来为当前用户的以下注册表项添加一个条目:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU\
我试图找出该注册表项中允许的最大值数,以便我可以让我的脚本添加另一个注册表项一个到最后。 值名称从字母表的开头开始,但我不想假设它们以“Z”结尾。
背景:我们正在重新打包一个专有(即不是我们自己的,我们无权访问源)应用程序并尝试设置其默认文件 -> 。 开放位置。 经过多次痛苦的快照和文件/Regmon 会话之后,这似乎是解决问题的方法。 我知道这很黑客,但它确实有效,我已经手动测试了该理论。 也就是说,我肯定愿意接受有关如何以更适合 Win32 的方式执行此操作的建议 - 假设应用程序自己没有更好的机制来执行此操作。
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 (i.e. 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于每个可执行文件名称,此注册表项保存该应用程序上次执行 SaveAs(也许是 Save,我不确定)的目录。
每个字母保存一个可执行文件的信息,
MRUList
保存顺序(这很重要)。我的在“y”处达到最大,我的
MRUList
是sxahmcjierfobglyuqpdtwvkn
。根据实验,当我从已有的应用程序执行“另存为”时,它只是替换该字母的信息并将其移动到 MRUList 的前面。
如果应用程序不存在并且并非所有字母都在
MRUList
中,它会获取第一个可用的字母,将信息放入该字母中,然后将该字母放在的前面MRUList
。如果应用程序不存在并且所有字母都已使用,它会获取 MRUList 上的最后一个字母,将信息放入该字母中,然后将其移至 MRUList 的前面/代码>。
我注意到,为一个全新的应用程序执行 SaveAs 不会给我 z 字母,它会重新使用“MRUList”中的最后一个字母。
键本身看起来就像 UCS-2(在我的澳大利亚版本的 Windows 中,16 位 Unicode、ASCII 与散布的空字节,您的情况可能会因国际变体而异),并且它们保存以 null 结尾的可执行文件名称,然后保存以 null 结尾的可执行文件名称。目录。
关于您关于无法访问该应用程序源的评论,这并不重要。 并不是那个应用程序改变了这些键。 ComDlg32 是 Windows 本身的常用对话框(打开、另存为、打印设置等)。
如果要为给定应用程序设置 MRU,请按照以下步骤操作。
1/ 在字母键中搜索该应用程序。 如果找到,请转到步骤 3。
2/ 获取
MRUList
中没有的下一个可用字母。 如果MRUList
已包含从a
到y
or 的所有字母,您不确信y
始终是最后一个字母(可以在注册表中的其他位置进行配置),抓住MRUList
末尾的最后一个字母。3/ 现在你收到了你的信。 使用应用程序和目录(均以 null 结尾)的 UCS-2 数据更改或创建该字母键。
4/ 更改
MRUList
将您的字母放在前面。那里。 应该可以做到这一点。
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
issxahmcjierfobglyuqpdtwvkn
.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 theMRUList
.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 theMRUList
.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 theMRUList
already has all the lettersa
throughy
or you're not confident thaty
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 theMRUList
.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
的属性,它指定对话框应打开到的目录。Unless I'm misunderstanding your situation, the standard Windows OpenFileDialog should have a property called
InitialDirectory
, which specifies the directory the dialog should open to.其他的重要吗? 我会考虑放弃其他的,或者重新使用第一个或最后一个。 (我也会尝试使用任何角色,但幸运的是它可能会起作用。)
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.)