function getSystemMACAddresses: TStringList;
var
l_WMILocator: ISWbemLocator;
// Locator, gets Services
l_WMIServices: ISWbemServices;
// Services, gets Object Definitions
l_WMIObjectDefinition: ISWbemObject;
// Definition, gets Set of Objetcs
l_WMIObjectSet: SWbemObjectSet;
// ObjectSet, gets Enum over Instances
l_WMIObjectInstances: IEnumVariant;
// Enum of Instances, gets Object
l_WMIObject: ISWbemObject;
// Object, gets Sets of his properties
l_WMIPropertySet: ISWbemPropertySet;
// PropertySet, gets single property
l_WMIProperty: ISWbemProperty;
// Property, gets Value
l_TempObj: OleVariant;
// temporary used values
l_ObjValue: Cardinal;
begin
EnterCriticalSection(Guard);
try
result := TStringList.Create;
// retrieve object enum through WMI classes
l_WMILocator := CoSWbemLocator.Create;
// <- CRASH ... aber nur mit MultiThread, a
//aber die komplette funktion ist ja geguardet
l_WMIServices := L_WMILocator.ConnectServer(WMI_LOCAL_COMPUTER, WMI_SYSTEM_NAMESPACE, '
', '
', '
', '
', 0,
nil);
l_WMIObjectDefinition := l_WMIServices.Get(WMI_CLASS_NIC, wbemFlagUseAmendedQualifiers,
nil);
l_WMIObjectSet := l_WMIObjectDefinition.Instances_(0,
nil);
l_WMIObjectInstances := (l_WMIObjectSet._NewEnum)
as IEnumVariant;
// iterate through enum values (WbemObjects) and get the property values
while (l_WMIObjectInstances.Next(1, l_TempObj, l_ObjValue) = S_OK)
do
begin
// retrieve object enum through WMI classes
l_WMILocator := CoSWbemLocator.Create;
l_WMIServices := L_WMILocator.ConnectServer(WMI_LOCAL_COMPUTER, WMI_SYSTEM_NAMESPACE, '
', '
', '
', '
', 0,
nil);
l_WMIObjectDefinition := l_WMIServices.Get(WMI_CLASS_NIC, wbemFlagUseAmendedQualifiers,
nil);
l_WMIObjectSet := l_WMIObjectDefinition.Instances_(0,
nil);
l_WMIObjectInstances := (l_WMIObjectSet._NewEnum)
as IEnumVariant;
// iterate through enum values (WbemObjects) and get the property values
while (l_WMIObjectInstances.Next(1, l_TempObj, l_ObjValue) = S_OK)
do
begin
l_WMIObject:= IUnknown(l_TempObj)
as SWBemObject;
l_WMIPropertySet := l_WMIObject.Properties_;
l_WMIProperty := l_WMIPropertySet.Item(WMI_ATTRIB_AVAILAB, 0);
if not VarIsNull(l_WMIProperty.Get_Value)
then
begin
Result.Add(l_WMIProperty.Get_Value);
l_WMIProperty := l_WMIPropertySet.Item(WMI_ATTRIB_CONNSTAT, 0);
if l_WMIProperty.Get_Value=2
then begin
result.Add('
C');
end
else
result.Add('
N');
end;
end;
end;
finally
LeaveCriticalSection(Guard);
end;
end;