200分求:★★★★★★★求VC中dll的头文件怎么转换成delphi★★★★★★★★(200分)

  • 主题发起人 lijianzhou
  • 开始时间
L

lijianzhou

Unregistered / Unconfirmed
GUEST, unregistred user!
以下是在C中定义的头文件,请问如何转换成delphi,谢谢!<br><br>// ClientApi.h: interface for the USSD API routines.<br>//<br>#ifndef &nbsp;__CLIENT_API<br>#define &nbsp;__CLIENT_API<br><br>#define &nbsp;MAX_MSISDN_LENGTH &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 20<br>#define &nbsp;MAX_SERVICECODE_LENGTH &nbsp; &nbsp; &nbsp; &nbsp;3<br>#define &nbsp;MAX_USSDSTRING_LENGTH &nbsp; &nbsp; &nbsp; &nbsp; 181<br><br>#define &nbsp;UT_REQUEST &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; // Request.<br>#define &nbsp;UT_NOTIFY &nbsp; &nbsp; &nbsp; &nbsp; 2 &nbsp; &nbsp; // Notify.<br>#define &nbsp;UT_RESPONSE &nbsp; &nbsp; &nbsp; 3 &nbsp; &nbsp; // Response.<br>#define &nbsp;UT_RELEASE &nbsp; &nbsp; &nbsp; &nbsp;4 &nbsp; &nbsp; // Release.<br><br>#define &nbsp;UV_UNKNOWN &nbsp; &nbsp; &nbsp; &nbsp;0x00 &nbsp;// 未知.<br>#define &nbsp;UV_PHASE_I &nbsp; &nbsp; &nbsp; &nbsp;0x10 &nbsp;// Phase I (只能由移动台发起)<br>#define &nbsp;UV_PHASE_II &nbsp; &nbsp; &nbsp; 0x20 &nbsp;// Phase II<br>#define &nbsp;UV_PHASE_II_PLUS &nbsp;0x25 &nbsp;// Phase II+<br><br>#define &nbsp;INVALID_INSTANCE_HANDLE &nbsp; ((HANDLE)-1)<br><br>struct TUssdSwitchInfo &nbsp; //业务转移信息<br>{<br> &nbsp; &nbsp;BYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_bSwitchMode;<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_szMsIsdn[MAX_MSISDN_LENGTH + 1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_szServiceCode[MAX_SERVICECODE_LENGTH + 1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_szUssdString[MAX_USSDSTRING_LENGTH + 1];<br>};<br><br>struct TUssdChargeIndInfo &nbsp;//计费指示信息<br>{<br> &nbsp; &nbsp;DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m_dwChargeRatio;<br> &nbsp; &nbsp;DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m_dwChargeType;<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_szChargeSource[MAX_MSISDN_LENGTH + 1];<br> &nbsp; &nbsp;BYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_bChargeLocation;<br>};<br><br>struct TUssdData<br>{<br> DWORD &nbsp;m_dwUssdCmd; &nbsp; &nbsp;// USSD会话操作类型(Request、Response、Abort、Error)<br> BYTE &nbsp; m_bUssdVersion; // USSD会话版本号(Phase I、Phase II、Phase II+)<br> &nbsp; &nbsp;BYTE &nbsp; m_bCodeScheme; &nbsp; //编码方案<br> DWORD &nbsp;m_dwErrorCode; // USSD错误代码(仅对UssdAbort和UssdError)<br> char &nbsp; m_szMsIsdn[MAX_MSISDN_LENGTH + 1]; &nbsp; &nbsp; &nbsp; &nbsp;// 移动台号码.<br> char &nbsp; m_szServiceCode[MAX_SERVICECODE_LENGTH + 1]; // 业务码.<br> char &nbsp; m_szUssdString[MAX_USSDSTRING_LENGTH + 1]; // USSD串内容。<br> DWORD &nbsp;m_dwUssdAppParam; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// USSD业务应用程序自定义的参数。<br>};<br><br>//-----------------------------------------------------------------------------<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CallBack Functions For GetMessage<br>//------------------------------------------------------------------------------<br>typedef int (*LPONUSSDREQUEST)(HANDLE hLoginInstance, HANDLE hUssdDialog,<br> &nbsp; &nbsp; &nbsp; &nbsp; TUssdData UssdData, DWORD *pdwUssdAppParam);<br>typedef int (*LPONUSSDRESPONSE)(HANDLE hLoginInstance, HANDLE hUssdDialog, <br> char szUssdString[], DWORD dwUssdAppParam);<br>typedef int (*LPONUSSDABORT)(HANDLE hLoginInstance, HANDLE hUssdDialog, <br> DWORD dwErrorCode, DWORD dwUssdAppParam);<br>typedef int (*LPONUSSDERROR)(HANDLE hLoginInstance, HANDLE hUssdDialog, <br> DWORD dwErrorCode, DWORD dwUssdAppParam);<br>typedef int (*LPONUSSDTIMEOUT)(HANDLE hLoginInstance, HANDLE hUssdDialog, <br> DWORD dwUssdAppParam);<br><br>struct TUssdCallbacks<br>{<br> &nbsp; &nbsp;LPONUSSDREQUEST &nbsp; m_pOnUssdRequest;<br> &nbsp; &nbsp;LPONUSSDRESPONSE &nbsp;m_pOnUssdResponse;<br> &nbsp; &nbsp;LPONUSSDABORT &nbsp; &nbsp; m_pOnUssdAbort;<br> &nbsp; &nbsp;LPONUSSDERROR &nbsp; &nbsp; m_pOnUssdError;<br> &nbsp; &nbsp;LPONUSSDTIMEOUT &nbsp; m_pOnUssdTimeOut;<br>};<br> <br>extern &quot;C&quot; <br>{<br>int &nbsp; &nbsp;PASCAL EXPORT UssdInit(char szServerAddress[],int nServicePort);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdExit();<br>HANDLE PASCAL EXPORT UssdLogin(char szAccountName[],char szPassword[],int *pnErrorCode,BOOL fAutoConnect,DWORD dwTimeOut);<br>BOOL &nbsp; PASCAL EXPORT UssdLogout(HANDLE hLoginInstance,int *pnErrorCode);<br>BOOL &nbsp; PASCAL EXPORT UssdIsConnectionOK(HANDLE hLoginInstance);<br>void &nbsp; PASCAL EXPORT UssdGetErrorString(int nErrorCode,char *pszErrorString);<br>BOOL &nbsp; PASCAL EXPORT UssdReloadErrorInfoLib();<br>HANDLE PASCAL EXPORT UssdLocalOpen(HANDLE hLoginInstance, DWORD dwUssdAppParam, DWORD *pdwErrorCode);<br>BOOL &nbsp; PASCAL EXPORT UssdLocalClose(HANDLE hUssdDialog);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendRequest(HANDLE hUssdDialog, TUssdData UssdData);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendNotify(HANDLE hUssdDialog, TUssdData UssdData);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendResponse(HANDLE hUssdDialog, TUssdData UssdData);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendRelease(HANDLE hUssdDialog);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendAbort(HANDLE hUssdDialog, &nbsp;DWORD dwErrorCode);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendError(HANDLE hUssdDialog, &nbsp;DWORD dwErrorCode);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendSwitch(HANDLE hUssdDialog, TUssdSwitchInfo SwitchInfo);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendChargeInd(HANDLE hUssdDialog, TUssdChargeIndInfo ChargeIndInfo);<br>int &nbsp; &nbsp;PASCAL EXPORT RegisterUssdCallbackFunctions(TUssdCallbacks CallbackFuncs);<br>};<br><br>#endif &nbsp; // __CLIENT_API defined.
 
#define &nbsp;MAX_MSISDN_LENGTH &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 20<br>#define &nbsp;MAX_SERVICECODE_LENGTH &nbsp; &nbsp; &nbsp; &nbsp;3<br>#define &nbsp;MAX_USSDSTRING_LENGTH &nbsp; &nbsp; &nbsp; &nbsp; 181<br><br><br>翻译为<br> <br>const<br> &nbsp;MAX_MSISDN_LENGTH &nbsp; &nbsp; &nbsp;= 20;<br> &nbsp;MAX_SERVICECODE_LENGTH = 3;<br> &nbsp;MAX_USSDSTRING_LENGTH &nbsp;= 181;<br><br>类似的常量以此类推<br><br>struct TUssdSwitchInfo &nbsp; //业务转移信息<br>{<br> &nbsp; &nbsp;BYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_bSwitchMode;<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_szMsIsdn[MAX_MSISDN_LENGTH + 1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_szServiceCode[MAX_SERVICECODE_LENGTH + 1];<br> &nbsp; &nbsp;char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_szUssdString[MAX_USSDSTRING_LENGTH + 1];<br>};<br><br>应翻译为<br><br>type<br> &nbsp;TUssdSwitchInfo = record<br> &nbsp; &nbsp;m_bSwitchMode : byte;<br> &nbsp; &nbsp;m_szMsIsdn : array [0..MAX_MSISDN_LENGTH] of char;<br> &nbsp; &nbsp;m_szServiceCode : array [0..MAX_SERVICECODE_LENGTH] of char;<br> &nbsp; &nbsp;m_szUssdString &nbsp;: array [0..MAX_USSDSTRING_LENGTH] of char;<br> &nbsp;end;<br><br>其他的以此类推<br><br>typedef &nbsp;int (*LPONUSSDREQUEST)(HANDLE hLoginInstance, HANDLE hUssdDialog,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TUssdData UssdData, DWORD *pdwUssdAppParam);<br><br>应翻译为<br><br>type<br> &nbsp;LPONUSSDREQUEST = function(hLoginInstance: THandle;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hussddialog: THANDLE;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;UssdData: TUssdData;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var pdwUssdAppParam : DWORD): Integer of object;<br><br>其他的以此类推<br><br>最后的是从DLL中导出函数接口的部分<br>如果使用的话应该就不需要翻译了<br>在Delphi下面是<br><br>exports<br> &nbsp;UssdInit....<br>以此类推
 
to iamy:<br>下面这两句怎么转啊:<br><br>#define &nbsp;UV_PHASE_II_PLUS &nbsp;0x25 &nbsp;// Phase II+<br><br>#define &nbsp;INVALID_INSTANCE_HANDLE &nbsp; ((HANDLE)-1)
 
UV_PHASE_II_PLUS = &nbsp;$25;<br>INVALID_INSTANCE_HANDLE &nbsp;= HANDLE-1;
 
定义成:<br>INVALID_INSTANCE_HANDLE &nbsp;=HANDLE-1;后抱错误,信息如下:<br>[Error] u_Const.pas(19): Undeclared identifier: 'HANDLE'
 
const UV_PHASE_II_PLUS = &nbsp;$25;<br>其它的头文件中应该有 HANDLE 的声明<br>看看你的程序中还包含了哪些头文件?
 
但是在delphi中怎么声明.目前就只有这个头文件了啊
 
ClientApi.h中包含(include)了哪些头文件?在相关的.h文件中搜索HANDLE
 
准备散分了.最后一个问题就是下面这些函数(其中之一)在delphi中的定义转换:<br>extern &quot;C&quot; <br>{<br>int &nbsp; &nbsp;PASCAL EXPORT UssdInit(char szServerAddress[],int nServicePort);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdExit();<br>HANDLE PASCAL EXPORT UssdLogin(char szAccountName[],char szPassword[],int *pnErrorCode,BOOL fAutoConnect,DWORD dwTimeOut);<br>BOOL &nbsp; PASCAL EXPORT UssdLogout(HANDLE hLoginInstance,int *pnErrorCode);<br>BOOL &nbsp; PASCAL EXPORT UssdIsConnectionOK(HANDLE hLoginInstance);<br>void &nbsp; PASCAL EXPORT UssdGetErrorString(int nErrorCode,char *pszErrorString);<br>BOOL &nbsp; PASCAL EXPORT UssdReloadErrorInfoLib();<br>HANDLE PASCAL EXPORT UssdLocalOpen(HANDLE hLoginInstance, DWORD dwUssdAppParam, DWORD *pdwErrorCode);<br>BOOL &nbsp; PASCAL EXPORT UssdLocalClose(HANDLE hUssdDialog);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendRequest(HANDLE hUssdDialog, TUssdData UssdData);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendNotify(HANDLE hUssdDialog, TUssdData UssdData);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendResponse(HANDLE hUssdDialog, TUssdData UssdData);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendRelease(HANDLE hUssdDialog);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendAbort(HANDLE hUssdDialog, &nbsp;DWORD dwErrorCode);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendError(HANDLE hUssdDialog, &nbsp;DWORD dwErrorCode);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendSwitch(HANDLE hUssdDialog, TUssdSwitchInfo SwitchInfo);<br>int &nbsp; &nbsp;PASCAL EXPORT UssdSendChargeInd(HANDLE hUssdDialog, TUssdChargeIndInfo ChargeIndInfo);<br>int &nbsp; &nbsp;PASCAL EXPORT RegisterUssdCallbackFunctions(TUssdCallbacks CallbackFuncs);<br>};
 
这个你不需要考虑的<br>这个是在VC里面导出的部分
 
在delphi里面需要使用他们<br>只要导入就可以了<br>提供静态调用的方法<br>以<br>int &nbsp; &nbsp;PASCAL EXPORT UssdInit(char szServerAddress[],int nServicePort);<br>为例<br><br><br>const<br> &nbsp;DLLName = '你的DLL文件名';<br>function UssInit(szServerAddress: PChar;nServicePort: Integer);external DLLName;stdcall;<br>注意<br>这里使用的是stdcall;<br>我不知道那个Pascal对应的是什么调用方式,因为对c++不太了解[:D]
 
多人接受答案了。
 
顶部