请问大家有没有翻译.h文件的经验(100分)

  • 主题发起人 主题发起人 big_jiang
  • 开始时间 开始时间
B

big_jiang

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟想用delphi实现一个在windows 下调用snmp的管理程序,发现微软已经提供了很好用的<br><br>动态链接库,而且很好用,现在我要做的就是将这些动态链接库的头文件 .h给翻译成.pas文件<br><br>现在遇到一点问题不知道应该怎么处理,恳请在座的大侠指点一下.<br><br>&nbsp; &nbsp; 我现在是在参考window.pas中的有关写法在翻译的,但是有些东西还是不很明白,希望有<br><br>人能有兴趣和时间和我共同研究一下.<br><br>&nbsp; &nbsp;以下是部分的snmp.h中的部分片断<br><br>#pragma pack(4) &nbsp;--------- 这个我就不知道该怎么处理了?<br><br>typedef struct {<br>&nbsp; &nbsp; BYTE * stream; &nbsp; &nbsp; <br>&nbsp; &nbsp; UINT &nbsp; length; &nbsp; &nbsp; <br>&nbsp; &nbsp; BOOL &nbsp; dynamic; &nbsp; &nbsp;<br>} AsnOctetString;<br><br>typedef struct {<br>&nbsp; &nbsp; UINT &nbsp; idLength; &nbsp; <br>&nbsp; &nbsp; UINT * ids; &nbsp; &nbsp; &nbsp; &nbsp;<br>} AsnObjectIdentifier;<br><br>typedef LONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnInteger32;<br>typedef ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AsnUnsigned32;<br>typedef ULARGE_INTEGER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnCounter64;<br>typedef AsnUnsigned32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AsnCounter32;<br>typedef AsnUnsigned32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AsnGauge32;<br>typedef AsnUnsigned32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AsnTimeticks;<br>typedef AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnBits;<br>typedef AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnSequence;<br>typedef AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnImplicitSequence;<br>typedef AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnIPAddress;<br>typedef AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnNetworkAddress;<br>typedef AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnDisplayString;<br>typedef AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnOpaque;<br><br>typedef struct {<br>&nbsp; &nbsp; BYTE asnType; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; union { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----------- 这个用什么处理比较好<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnInteger32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;number; &nbsp; &nbsp; // ASN_INTEGER<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // ASN_INTEGER32<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnUnsigned32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unsigned32; // ASN_UNSIGNED32<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnCounter64 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;counter64; &nbsp;// ASN_COUNTER64<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnOctetString &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string; &nbsp; &nbsp; // ASN_OCTETSTRING<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnBits &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bits; &nbsp; &nbsp; &nbsp; // ASN_BITS<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnObjectIdentifier &nbsp; &nbsp; object; &nbsp; &nbsp; // ASN_OBJECTIDENTIFIER<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnSequence &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sequence; &nbsp; // ASN_SEQUENCE<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnIPAddress &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;address; &nbsp; &nbsp;// ASN_IPADDRESS<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnCounter32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;counter; &nbsp; &nbsp;// ASN_COUNTER32<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnGauge32 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;gauge; &nbsp; &nbsp; &nbsp;// ASN_GAUGE32<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnTimeticks &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ticks; &nbsp; &nbsp; &nbsp;// ASN_TIMETICKS<br>&nbsp; &nbsp; &nbsp; &nbsp; AsnOpaque &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arbitrary; &nbsp;// ASN_OPAQUE<br>&nbsp; &nbsp; } asnValue;<br>} AsnAny;<br><br>typedef AsnObjectIdentifier &nbsp; &nbsp; AsnObjectName;<br>typedef AsnAny &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AsnObjectSyntax;<br><br>typedef struct {<br>&nbsp; &nbsp; AsnObjectName &nbsp; &nbsp;name; &nbsp; &nbsp; <br>&nbsp; &nbsp; AsnObjectSyntax &nbsp;value; &nbsp; &nbsp;<br>} SnmpVarBind;<br><br>typedef struct {<br>&nbsp; &nbsp; SnmpVarBind * list; &nbsp; &nbsp; <br>&nbsp; &nbsp; UINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;len; &nbsp; &nbsp; &nbsp;<br>} SnmpVarBindList;<br><br>#pragma pack()<br><br><br>#define SNMPAPI &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INT<br>#define SNMP_FUNC_TYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WINAPI<br><br>#define SNMPAPI_NOERROR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TRUE<br>#define SNMPAPI_ERROR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FALSE<br><br>///////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// SNMP Extension API Prototypes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>///////////////////////////////////////////////////////////////////////////////<br><br>BOOL <br>SNMP_FUNC_TYPE &nbsp; &nbsp;---------------------- 这些怎么处理 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>SnmpExtensionInit(<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwUptimeReference, &nbsp; &nbsp;<br>&nbsp; &nbsp; HANDLE * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;phSubagentTrapEvent, &nbsp;<br>&nbsp; &nbsp; AsnObjectIdentifier * pFirstSupportedRegion <br>&nbsp; &nbsp; );<br><br><br><br>BOOL <br>SNMP_FUNC_TYPE<br>SnmpExtensionInitEx(<br>&nbsp; &nbsp; AsnObjectIdentifier * pNextSupportedRegion<br>&nbsp; &nbsp; );<br><br><br><br>VOID<br>SNMP_FUNC_TYPE<br>SnmpUtilDbgPrint(<br>&nbsp; &nbsp; IN INT nLogLevel, &nbsp; // see log levels above...<br>&nbsp; &nbsp; IN LPSTR szFormat,<br>&nbsp; &nbsp; IN ...<br>&nbsp; &nbsp; );<br><br><br>-------------------------------------------以下的内容又如何处理呢<br>#if DBG<br>#define SNMPDBG(_x_) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SnmpUtilDbgPrint _x_<br>#else<br>#define SNMPDBG(_x_)<br>#endif<br><br>///////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// Miscellaneous definitions &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>///////////////////////////////////////////////////////////////////////////////<br><br>#define DEFINE_SIZEOF(Array) &nbsp; &nbsp; &nbsp; &nbsp;(sizeof(Array)/sizeof((Array)[0]))<br>#define DEFINE_OID(SubIdArray) &nbsp; &nbsp; &nbsp;{DEFINE_SIZEOF(SubIdArray),(SubIdArray)}<br>#define DEFINE_NULLOID() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{0,NULL} <br>#define DEFINE_NULLOCTETS() &nbsp; &nbsp; &nbsp; &nbsp; {NULL,0,FALSE}<br><br><br>恳请指点<br><br><br><br><br><br><br><br><br><br>
 
我啊!<br>snmp.h我只翻译了一小部分,加在我的程序中了,&lt;a href="http://www.qzone.com/home/o/oo/oopsware/home/download/Netstat.zip"&gt;下载&lt;a&gt;
 
多谢指点,很受启发<br><br>现在贴出来给大家看一下<br><br>&nbsp;TAsnOctetString = record<br>&nbsp; &nbsp; stream: pByte;<br>&nbsp; &nbsp; length: Cardinal;<br>&nbsp; &nbsp; dynamic: Boolean;<br>&nbsp; end;<br><br>&nbsp; TAsnObjectIdentifier = record<br>&nbsp; &nbsp; idLength: Cardinal;<br>&nbsp; &nbsp; ids: Pointer;<br>&nbsp; end;<br>&nbsp; pAsnObjectIdentifier = ^TAsnObjectIdentifier;<br><br>&nbsp; TAsnObjectSyntax = record<br>&nbsp; &nbsp; case asnType: Byte of<br>&nbsp; &nbsp; &nbsp;0: (number: LongInt);<br>&nbsp; &nbsp; &nbsp;1: (unsigned32: Cardinal);<br>&nbsp; &nbsp; &nbsp;2: (counter64: Int64);<br>&nbsp; &nbsp; &nbsp;3: (AsnString: TAsnOctetString);<br>&nbsp; &nbsp; &nbsp;4: (bits: TAsnOctetString);<br>&nbsp; &nbsp; &nbsp;5: (AsnObject: TAsnObjectIdentifier);<br>&nbsp; &nbsp; &nbsp;7: (sequence: TAsnOctetString);<br>&nbsp; &nbsp; &nbsp;8: (address: TAsnOctetString);<br>&nbsp; &nbsp; &nbsp;9: (counter: Cardinal);<br>&nbsp; &nbsp; &nbsp;10:(gauge: Cardinal);<br>&nbsp; &nbsp; &nbsp;11:(ticks: Cardinal);<br>&nbsp; &nbsp; &nbsp;12:(arbitrary: TAsnOctetString);<br>&nbsp; end;<br><br>&nbsp; TRFC1157VarBind = record<br>&nbsp; &nbsp; name: TAsnObjectIdentifier;<br>&nbsp; &nbsp; value: TAsnObjectSyntax;<br>&nbsp; end;<br>&nbsp; pRFC1157VarBind = ^TRFC1157VarBind;<br><br>&nbsp; TRFC1157VarBindList = record<br>&nbsp; &nbsp; list: pRFC1157VarBind;<br>&nbsp; &nbsp; len: DWord<br>&nbsp; end;<br>&nbsp; pRFC1157VarBindList = ^TRFC1157VarBindList;<br><br>&nbsp;TSnmpExtensionInit = function(dwTimeZeroReference:DWord;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hPollForTrapEvent: PHandle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pFirstSupportedRegion: pAsnObjectIdentifier<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ):Boolean; stdcall;<br><br>&nbsp; TSnmpExtensionQuery = function(requestType: Byte;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;variableBindings: pRFC1157VarBindList;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorStatus: pLongInt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errorIndex: pLongInt<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;):Boolean; stdcall;
 
后退
顶部