Registriert seit: 31. Dez 2004
Ort: Stuttgart
4.408 Beiträge
Delphi XE8 Enterprise
|
Sporadische Zugriffsverletzung bei LoadLibrary
28. Mai 2008, 18:44
Hallo zusammmen,
in der nachfolgenden Procedure meldet sich EurekaLog mit zwei Zeilen. Ich kann aber nicht richtig nachvollziehen, warum er sich gerade an den beiden Stellen meldet :
Delphi-Quellcode:
procedure TNetworkInfos.GetAdapterAddresses(AdapterName: string;
var Ethertype, DNSSuffix, FriendlyName:string;
var LinkSpeed :int64; var Mtu, Flags: integer);
var
adapteraddr:pip_adapter_addresses;
buffer:dword;
Error:dword;
hdll: THandle;
AdaptersAddresses: TGetAdapterAdresses;
FixedInfo: PFixedInfo;
BufLen: ULONG;
reg: TRegistry;
I: Integer;
TempAdapterName: string;
begin // <--- Erste Zeile wo EurekaLog sich meldet
hdll := LoadLibrary('IPHLPAPI.DLL');
if hdll <> 0 then
begin
@AdaptersAddresses := GetProcAddress(hdll, 'GetAdaptersAddresses');
if @AdaptersAddresses <> nil then
begin
error := AdaptersAddresses(AF_UNSPEC, 10, nil, nil, @buffer);
if error <> ERROR_BUFFER_OVERFLOW then
exit;
adapteraddr := AllocMem(buffer);
error := AdaptersAddresses(AF_UNSPEC, 10, nil, adapteraddr, @buffer);
if error = ERROR_SUCCESS then
begin
while adapteraddr.Next <> nil do
begin
if AdapterName = adapteraddr.AdapterName then
begin
case adapteraddr.IfType of
IF_TYPE_ETHERNET_CSMACD : EtherType := 'Ethernet';
IF_TYPE_SOFTWARE_LOOPBACK : EtherType := 'Loopback';
IF_TYPE_TUNNEL : EtherType := 'Tunnel';
IF_TYPE_IEEE1394 : EtherType := 'FireWire 1394';
IF_TYPE_IEEE80211 : EtherType := 'WLAN - Interface';
IF_TYPE_PPP : EtherType := 'PPP - Interface';
end;
DNSSuffix := WideCharToString(adapteraddr.DnsSuffix);
FriendlyName := WideCharToString(adapteraddr.FriendlyName);
LinkSpeed := round(adapteraddr.ReceiveLinkSpeed / 1000000);
Mtu := adapteraddr.Mtu;
Flags := adapteraddr.Flags;
end;
adapteraddr := adapteraddr.Next;
end;
end //<--- Zweite Zeile wo sich EurekaLog meldet
else
begin
FreeLibrary(hdll);
exit;
end;
end
else
begin
TempAdapterName := '';
FixedInfo := PFIXEDINFO( GlobalAlloc( GPTR, sizeof(FIXEDINFO) ) );
BufLen := sizeof( FIXEDINFO );
if GetNetworkParams(FixedInfo, @BufLen) = ERROR_BUFFER_OVERFLOW then
begin
GlobalFree( Cardinal(FixedInfo) );
FixedInfo := PFIXEDINFO( GlobalAlloc( GPTR, BufLen ) );
end;
if GetNetworkParams(FixedInfo, @BufLen) = ERROR_SUCCESS then
begin
DNSSuffix := FixedInfo.DomainName;
end;
GlobalFree( Cardinal(FixedInfo) );
case pAdapterList.dwType of
IF_TYPE_ETHERNET_CSMACD : EtherType := 'Ethernet';
IF_TYPE_SOFTWARE_LOOPBACK : EtherType := 'Loopback';
IF_TYPE_TUNNEL : EtherType := 'Tunnel';
IF_TYPE_IEEE1394 : EtherType := 'FireWire 1394';
IF_TYPE_IEEE80211 : EtherType := 'WLAN - Interface';
IF_TYPE_PPP : EtherType := 'PPP - Interface';
end;
reg := TRegistry.Create();
reg.RootKey := HKEY_LOCAL_MACHINE;
try
for I := 0 to Length(pAdapterList.AdapterName) - 1 do
if pAdapterList.AdapterName[i] <> '' then
TempAdapterName := TempAdapterName + pAdapterList.AdapterName[i];
if reg.OpenKeyReadOnly(w2knetcard + '\' + TempAdapterName + '\Connection') then
FriendlyName := reg.ReadString('Name')
else
FriendlyName := 'unbekannt';
finally
reg.CloseKey;
reg.Free;
end;
end;
FreeLibrary(hdll);
end;
end;
Könnt Ihr mir da irgendwie weiterhelfen ?
|
|
Zitat
|