在Inno Setup中获取MAC地址 [英] Get MAC address in Inno Setup
本文介绍了在Inno Setup中获取MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试下面的代码在Inno Setup中获取mac地址,但出现错误
I tried the below code to get the mac address in Inno Setup but getting an error as
内部错误:ExtractTemporaryFile:找不到文件"ISID.dll".
Internal error: ExtractTemporaryFile: The file "ISID.dll" was not found.
我已将ISID.dll
复制到应用程序文件夹中,但仍然出现上述错误.
I have copied the ISID.dll
in the application folder still getting the above error.
请让我知道我是否缺少某些东西....:
Please let me know if I am missing something....:
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地址.
Here is a script which uses WMI on Windows to get all MAC addresses.
[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;
这篇关于在Inno Setup中获取MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文