gpt4 book ai didi

delphi - 如何在 Windows 7 中获取域名

转载 作者:行者123 更新时间:2023-12-03 15:24:19 28 4
gpt4 key购买 nike

我编写了一个运行 Excel 加载项的 dll(几年前)。

我使用此代码检索域名,在 Windows XP 中工作正常,但在 Windows 7 中失败。
当我以管理员身份运行时它才有效。
但是我不想以管理员身份运行,因为此代码是 Excel 加载项 dll 的一部分,如果以管理员身份运行,Excel 无法找到用户的文件。

MyReg:= TRegistry.Create;

MyReg.RootKey:= HKEY_LOCAL_MACHINE;
MyReg.OpenKey(RegKeyWin7,false);
NetworkID2:= lowercase(trim(MyReg.ReadString(RegValWin7)));
MyReg.CloseKey;

FreeAndNil(MyReg);

FNetworkOK:= (NetworkID2 = OKRes4);
//Temp check to pinpoint the problem.
if FNetWorkOK = false then ShowMessage('Error wrong domain: '+NetworkID2)
else ShowMessage('all ok');

如何在正常权限下使用 Delphi 在 Windows 7 中检索域名?

最佳答案

使用NetWkstaGetInfo在 Win32 API 中,通过 level value = 100 请求信息。

Return information about the workstation environment, including platform-specific information, the name of the domain and the local computer, and information concerning the operating system. The bufptr parameter points to a WKSTA_INFO_100 structure.

关于delphi - 如何在 Windows 7 中获取域名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6412289/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com