在Windows 7 64位上从Delphi 7读取注​​册表的问题

前端之家收集整理的这篇文章主要介绍了在Windows 7 64位上从Delphi 7读取注​​册表的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我认为这个问题已经被问到了,但我找不到适合我的解决方案.我在 Windows 7旗舰版,64位下使用Delphi 7.实际上我开始在32位操作系统下编写应用程序,但随后更改了PC,所以现在更改为64.在我的程序中,我使用注册过程,从Windows的PROGID值生成许可证ID.不幸的是,它没有读取值,似乎它正在寻找一个不同的文件夹,可能被Windows 64重定向到32位注册表.你能帮我吗?这是我使用的代码

@H_301_11@Registry := TRegistry.Create(KEY_READ OR $0100); try Registry.Lazywrite := false; Registry.RootKey := HKEY_LOCAL_MACHINE; if CheckForWinNT = true then Begin if not Registry.OpenKeyReadOnly('\Software\Microsoft\Windows NT\CurrentVersion') then showmessagE('cant open'); end else Registry.OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion'); result := Registry.ReadString('ProductID'); Registry.CloseKey; finally Registry.Free; end; // try..finally

另外,您知道如何在Delphi 7中查找程序是在64位还是32位计算机下运行?

解决方法

您已经问过这个问题,请参阅 Registry ReadString method is not working in Windows 7 in Delphi 7.

所以你知道你必须在TRegistry.Create中添加$0100.您的代码的问题是您使用OpenKeyReadOnly将注册表的Access属性重置为KEY_READ,因此KEY_READ或$0100将丢失.

只需使用OpenKey而不是OpenKeyReadOnly,这不会重置您的Access属性.

猜你在找的Windows相关文章