当前位置 : 主页 > 编程语言 > delphi >

为Delphi翻译Vista WinAPI C标头 – 有什么建议吗?

来源:互联网 收集:自由互联 发布时间:2021-06-23
我需要从我的Delphi应用程序调用Vista中引入的 Windows API函数,但我没有任何描述该函数的Delphi头文件. 相关功能已在JEDI Windows API库中记录,但不是此功能. 我的C几乎不存在,我正在努力计算
我需要从我的Delphi应用程序调用Vista中引入的 Windows API函数,但我没有任何描述该函数的Delphi头文件.

相关功能已在JEDI Windows API库中记录,但不是此功能.

我的C几乎不存在,我正在努力计算出与MSDN上记载的函数及其参数相对应的Delphi定义.

从http://msdn.microsoft.com/en-us/library/aa814417.aspx起

NETIOAPI_API GetIpInterfaceEntry(__inout  PMIB_IPINTERFACE_ROW Row);

typedef struct _MIB_IPINTERFACE_ROW {
  ADDRESS_FAMILY                 Family;
  NET_LUID                       InterfaceLuid;
  NET_IFINDEX                    InterfaceIndex;
  ULONG                          MaxReassemblySize;
  ULONG64                        InterfaceIdentifier;
  ULONG                          MinRouterAdvertisementInterval;
  ULONG                          MaxRouterAdvertisementInterval;
  BOOLEAN                        AdvertisingEnabled;
  BOOLEAN                        ForwardingEnabled;
  BOOLEAN                        WeakHostSend;
  BOOLEAN                        WeakHostReceive;
  BOOLEAN                        UseAutomaticMetric;
  BOOLEAN                        UseNeighborUnreachabilityDetection;
  BOOLEAN                        ManagedAddressConfigurationSupported;
  BOOLEAN                        OtherStatefulConfigurationSupported;
  BOOLEAN                        AdvertiseDefaultRoute;
  NL_ROUTER_DISCOVERY_BEHAVIOR   RouterDiscoveryBehavior;
  ULONG                          DadTransmits;
  ULONG                          BaseReachableTime;
  ULONG                          RetransmitTime;
  ULONG                          PathMtuDiscoveryTimeout;
  NL_LINK_LOCAL_ADDRESS_BEHAVIOR LinkLocalAddressBehavior;
  ULONG                          LinkLocalAddressTimeout;
  ULONG                          ZoneIndices[ScopeLevelCount];
  ULONG                          SitePrefixLength;
  ULONG                          Metric;
  ULONG                          NlMtu;
  BOOLEAN                        Connected;
  BOOLEAN                        SupportsWakeUpPatterns;
  BOOLEAN                        SupportsNeighborDiscovery;
  BOOLEAN                        SupportsRouterDiscovery;
  ULONG                          ReachableTime;
  NL_INTERFACE_OFFLOAD_ROD       TransmitOffload;
  NL_INTERFACE_OFFLOAD_ROD       ReceiveOffload;
  BOOLEAN                        DisableDefaultRoutes;
}MIB_IPINTERFACE_ROW, *PMIB_IPINTERFACE_ROW;

在其他位中,我正在努力争取的位是ZoneIndices [ScopeLevelCount]字段;我无法确定数组的大小.

这是我到目前为止所定义的,尽管我还没有在原始C定义中编写枚举.我将在Vista上明确加载Windows DLL并获取要调用的新函数的地址.

type
  PMIB_IPINTERFACE_ROW = ^MIB_IPINTERFACE_ROW;
  {$EXTERNALSYM PMIB_IPINTERFACE_ROW}
  _MIB_IPINTERFACE_ROW = record
    Family: ADDRESS_FAMILY;
    InterfaceLuid: NET_LUID;
    InterfaceIndex: NET_IFINDEX;
    MaxReassemblySize,
    InterfaceIdentifier,
    MinRouterAdvertisementInterval,
    MaxRouterAdvertisementInterval: Cardinal;
    AdvertisingEnabled,
    ForwardingEnabled,
    WeakHostSend,
    WeakHostReceive,
    UseAutomaticMetric,
    UseNeighborUnreachabilityDetection,
    ManagedAddressConfigurationSupported,
    OtherStatefulConfigurationSupported,
    AdvertiseDefaultRoute: LongBool;
    RouterDiscoveryBehavior: NL_ROUTER_DISCOVERY_BEHAVIOR;
    DadTransmits,
    BaseReachableTime,
    RetransmitTime,
    PathMtuDiscoveryTimeout: Cardinal;
    LinkLocalAddressBehavior: NL_LINK_LOCAL_ADDRESS_BEHAVIOR;
    LinkLocalAddressTimeout,
    ZoneIndices[ScopeLevelCount],
    SitePrefixLength,
    Metric,
    NlMtu: Cardinal;
    Connected,
    SupportsWakeUpPatterns,
    SupportsNeighborDiscovery,
    SupportsRouterDiscovery: LongBool;
    ReachableTime: Cardinal;
    TransmitOffload: NL_INTERFACE_OFFLOAD_ROD;
    ReceiveOffload: NL_INTERFACE_OFFLOAD_ROD;
    DisableDefaultRoutes: LongBool;
  end;
  {$EXTERNALSYM _MIB_IPINTERFACE_ROW}
  MIB_IPINTERFACE_ROW = _MIB_IPINTERFACE_ROW;
  {$EXTERNALSYM MIB_IPINTERFACE_ROW}
  TMibIpInterfaceRow = MIB_IPINTERFACE_ROW;
  PMibIpInterfaceRow = PMIB_IPINTERFACE_ROW;

const
  iphlpapilib = 'iphlpapi.dll';

var
  HIpHlpApi: THandle = 0;
  GetIpInterfaceEntry: function(const pArpEntry: MIB_IPINTERFACE_ROW): LongInt; stdcall;
  {$EXTERNALSYM GetIpInterfaceEntry}

有没有人有翻译像这样的功能定义的建议或提示/技巧?

非常感谢,

康纳尔

Win32 BOOLEAN类型是一个字节,但Delphi的LongBool类型是四个.请改用Delphi的ByteBool.
网友评论