我尝试使用下面的代码来获取 Inno Setup 中的 mac 地址,但出现错误:
内部错误:ExtractTemporaryFile:找不到文件“ISID.dll”。
我已经复制了ISID.dll
在应用程序文件夹中仍然出现上述错误。
如果我遗漏了什么,请告诉我......:
function GetMacAddress(output:string): Integer;
external 'GetMACAddress@files:ISID.dll stdcall';
function GetMacAdd(Output: string): string;
var
ClassName: String;
Ret: Integer;
begin
SetLength(ClassName, 256);
Ret := GetMacAddress(PChar(ClassName));
Result := Copy(ClassName, 1, Ret);
end;
这是一个在 Windows 上使用 WMI 获取所有 MAC 地址的脚本。
[Code]
type
TMacAddressEntry = record
MacAddress: string;
end;
TMacAddressesList = array of TMacAddressEntry;
function GetMacAddressesList(out List: TMacAddressesList): Integer;
var
I: Integer;
WQLQuery: string;
WbemLocator: Variant;
WbemServices: Variant;
WbemObject: Variant;
WbemObjectSet: Variant;
begin
Result := 0;
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('localhost', 'root\cimv2');
WQLQuery := 'Select * from Win32_NetworkAdapterConfiguration where IPEnabled=true';
WbemObjectSet := WbemServices.ExecQuery(WQLQuery);
if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
begin
Result := WbemObjectSet.Count;
SetArrayLength(List, WbemObjectSet.Count);
for I := 0 to WbemObjectSet.Count - 1 do
begin
WbemObject := WbemObjectSet.ItemIndex(I);
if not VarIsNull(WbemObject) then
begin
List[I].MacAddress := WbemObject.MACAddress;
end;
end;
end;
end;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)