{****************************************************************************
** **
** PSSDK HNAdapterConfig module **
** Copyright (c) 1997 - 2007 microOLAP Technologies LTD, **
** Khalturin A.P., Naumov D.A. **
** **
****************************************************************************}
unit HNAdapterConfig;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
HNPSManager, HNPsSdkDef;
type
//---------------------------------------------------------------------------
// Class THNAdapterConfig
//---------------------------------------------------------------------------
THNAdapterConfig = class
private
hCfg : Pointer;
private
function GetAdapterName: AnsiString;
function GetAccessibleState: BOOL;
function GetAdapterDescription: AnsiString;
function GetAdapterType: DWORD;
function GetMaxPacketSize: DWORD;
function GetMACAddrSize: DWORD;
function GetMACHeaderSize: DWORD;
function GetZeroBroadcastState: BOOL;
function GetDhcpState: BOOL;
function GetIpCount: DWORD;
function GetIpDhcpCount: DWORD;
function GetIpGatewayCount: DWORD;
function GetIpDnsCount: DWORD;
// Add in 3.2
function GetIsWireless: BOOL;
protected
public
constructor Create();
destructor Destroy(); override;
public
function IsValid: BOOL;
function Get_MACAddress(pMACAddr: Pointer; BuffSize : DWORD): DWORD;
function Get_Ip(Index: DWORD): AnsiString;
function Get_SubnetMask(Index: DWORD): AnsiString;
function Get_IpDhcp(Index: DWORD): AnsiString;
function Get_IpGateway(Index: DWORD): AnsiString;
function Get_IpDns(Index: DWORD): AnsiString;
function Update(ChangeType: DWORD): DWORD;
property Handle: Pointer read hCfg write hCfg;
property AdapterName: AnsiString read GetAdapterName;
property AccessibleState: BOOL read GetAccessibleState;
property AdapterDescription: AnsiString read GetAdapterDescription;
property AdapterType: DWORD read GetAdapterType;
property MaxPacketSize: DWORD read GetMaxPacketSize;
property MACAddrSize: DWORD read GetMACAddrSize;
property MACHeaderSize: DWORD read GetMACHeaderSize;
property ZeroBroadcastState: BOOL read GetZeroBroadcastState;
property DhcpState: BOOL read GetDhcpState;
property IpCount: DWORD read GetIpCount;
property IpDhcpCount: DWORD read GetIpDhcpCount;
property IpGatewayCount: DWORD read GetIpGatewayCount;
property IpDnsCount: DWORD read GetIpDnsCount;
// Add in 3.2
property IsWireless: BOOL read GetIsWireless;
published
end;
implementation
{$INCLUDE 'HNPsSdkFun.pas'}
//---------------------------------------------------------------------------
// Create - Creates the HNAdapterConfig object.
//---------------------------------------------------------------------------
constructor THNAdapterConfig.Create();
begin
hCfg := nil;
end;
//---------------------------------------------------------------------------
// Destroy - Destroys the HNAdapterConfig object.
//---------------------------------------------------------------------------
destructor THNAdapterConfig.Destroy();
begin
end;
//---------------------------------------------------------------------------
// Method - IsValid - Checks the correctness of the HNAdapterConfig object handle settings.
//---------------------------------------------------------------------------
function THNAdapterConfig.IsValid: BOOL;
begin
Result := BOOL(hCfg <> nil);
end;
//---------------------------------------------------------------------------
// Property - AdapterName - Returns the network adapter system name.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetAdapterName: AnsiString;
begin
Result := AdpCfgGetAdapterName(hCfg);
end;
//---------------------------------------------------------------------------
// Property - AccessibleState - Returns the network adapter accessibility status.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetAccessibleState: BOOL;
begin
Result := AdpCfgGetAccessibleState(hCfg);
end;
//---------------------------------------------------------------------------
// Property - AdapterDescription - Returns the network adapter description.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetAdapterDescription: AnsiString;
begin
Result := AdpCfgGetAdapterDescription(hCfg);
end;
//---------------------------------------------------------------------------
// Property - AdapterType - Returns the network adapter type.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetAdapterType: DWORD;
begin
Result := AdpCfgGetAdapterType(hCfg);
end;
//---------------------------------------------------------------------------
// Property - MaxPacketSize - Returns the network adapter packet maximum size.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetMaxPacketSize: DWORD;
begin
Result := AdpCfgGetMaxPacketSize(hCfg);
end;
//---------------------------------------------------------------------------
// Property - MACAddrSize - Returns the MAC address size.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetMACAddrSize: DWORD;
begin
Result := AdpCfgGetMACAddrSize(hCfg);
end;
//---------------------------------------------------------------------------
// Method - Get_MACAddress - Returns the MAC address of the network adapter.
//---------------------------------------------------------------------------
function THNAdapterConfig.Get_MACAddress(pMACAddr: Pointer; BuffSize : DWORD): DWORD;
begin
Result := AdpCfgGetMACAddress(hCfg,pMACAddr,BuffSize);
end;
//---------------------------------------------------------------------------
// Property - MACHeaderSize - Returns the MAC header size.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetMACHeaderSize: DWORD;
begin
Result := AdpCfgGetMACHeaderSize(hCfg);
end;
//---------------------------------------------------------------------------
// Property - ZeroBroadcastState - Returns the status of IP zero broadcast usage.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetZeroBroadcastState: BOOL;
begin
Result := AdpCfgGetZeroBroadcastState(hCfg);
end;
//---------------------------------------------------------------------------
// Property - DhcpState - Returns the status of the DHCP using.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetDhcpState: BOOL;
begin
Result := AdpCfgGetDhcpState(hCfg);
end;
//---------------------------------------------------------------------------
// Property - IpCount - Returns the number of IP addresses, assigned to the network adapter card.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetIpCount: DWORD;
begin
Result := AdpCfgGetIpCount(hCfg);
end;
//---------------------------------------------------------------------------
// Method - Get_Ip - Returns one of the IP addresses, assigned to the network adapter.
//---------------------------------------------------------------------------
function THNAdapterConfig.Get_Ip(Index: DWORD): AnsiString;
begin
Result := AdpCfgGetIp(hCfg,Index);
end;
//---------------------------------------------------------------------------
// Method - Get_SubnetMask - Returns the subnet mask that matches to the corresponding IP address index.
//---------------------------------------------------------------------------
function THNAdapterConfig.Get_SubnetMask(Index: DWORD): AnsiString;
begin
Result := AdpCfgGetSubnetMask(hCfg,Index);
end;
//---------------------------------------------------------------------------
// Property - IpDhcpCount - Returns the number of the IP addresses of DHCP servers set on the system.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetIpDhcpCount: DWORD;
begin
Result := AdpCfgGetIpDhcpCount(hCfg);
end;
//---------------------------------------------------------------------------
// Method - Get_IpDhcp - Returns one of the IP addresses of DHCP servers set on the system.
//---------------------------------------------------------------------------
function THNAdapterConfig.Get_IpDhcp(Index: DWORD): AnsiString;
begin
Result := AdpCfgGetIpDhcp(hCfg,Index);
end;
//---------------------------------------------------------------------------
// Property - IpGatewayCount - Returns the number of the gateways IP addresses.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetIpGatewayCount: DWORD;
begin
Result := AdpCfgGetIpGatewayCount(hCfg);
end;
//---------------------------------------------------------------------------
// Method - Get_IpGateway - Returns one of the IP addresses of the gateways set on the system.
//---------------------------------------------------------------------------
function THNAdapterConfig.Get_IpGateway(Index: DWORD): AnsiString;
begin
Result := AdpCfgGetIpGateway(hCfg,Index);
end;
//---------------------------------------------------------------------------
// Property - IpDnsCount - Returns the number of the IP addresses of DNS servers set on the system.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetIpDnsCount: DWORD;
begin
Result := AdpCfgGetIpDnsCount(hCfg);
end;
//---------------------------------------------------------------------------
// Method - Get_IpDns - Returns one of the IP addresses of the DNS servers set on the system.
//---------------------------------------------------------------------------
function THNAdapterConfig.Get_IpDns(Index: DWORD): AnsiString;
begin
Result := AdpCfgGetIpDns(hCfg,Index);
end;
//---------------------------------------------------------------------------
// Method - Update - Updates the network adapter configuration.
//---------------------------------------------------------------------------
function THNAdapterConfig.Update(ChangeType: DWORD): DWORD;
begin
Result := AdpCfgUpdate(hCfg,ChangeType);
end;
//---------------------------------------------------------------------------
// v3.2 - Property - IsWireless - Return the value of the flag which indicates that the network adapter actually is wireless (802.11) device.
//---------------------------------------------------------------------------
function THNAdapterConfig.GetIsWireless(): BOOL;
begin
Result := AdpCfgIsWireless(hCfg);
end;
end.