【发布时间】:2011-09-18 17:31:22
【问题描述】:
我编写了一个运行 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');
在 Windows 7 中如何在正常权限下使用 Delphi 检索域名?
【问题讨论】:
标签: delphi dll windows-7 dns delphi-2007