哪位熟悉C语言和Delphi语言的高手帮我翻译一下?有点难度!(200分)

H

hua8hua

Unregistered / Unconfirmed
GUEST, unregistred user!
哪位熟悉C语言和Delphi语言的高手可否帮我翻译一下,把下面翻译成Delphi语法,
主要是那个回调函数,搞不懂!谢谢!
transfer.h

#ifndef _TRANSFER_H_
#define _TRANSFER_H_
#if !defined(_TRANSFERLIBAPI_)
#define TRANSFERLIB _declspec(dllimport)
#else
#define TRANSFERLIB _declspec(dllexport)
#endif
// Notify Message
#define TRANSFER_CABLE_ATTACH 1 // lParam (DWORD) - which cable
#define TRANSFER_CABLE_DETACH 2 // lParam (DWORD) - which cable
#define TRANSFER_PEER_SOFTWARE_EXIST 3 // lParam (DWORD) - which cable
#define TRANSFER_PEER_SOFTWARE_QUIT 4 // lParam (DWORD) - which cable
#define TRANSFER_RESET_RECEIVE 5 // lParam (DWORD) - which cable
#define TRANSFER_RESET_SEND 6 // lParam (DWORD) - which cable
// private type definition
// == void *
DECLARE_HANDLE(HCONNECT);

// callback function
typedef void (CALLBACK *NOTIFYPROC)(UINT nNofityMsg, LPARAM lParam);

// function prototypes
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
BOOL APIENTRY DllMain(HANDLE hInstDll, DWORD dwReason, LPVOID lpReserved);
TRANSFERLIB BOOL APIENTRY USB_InitService(NOTIFYPROC fnNotifyProc);
TRANSFERLIB void APIENTRY USB_ReleaseService(void);
TRANSFERLIB HCONNECT APIENTRY USB_OpenConnect(LPCSTR lpConnectName);
TRANSFERLIB void APIENTRY USB_CloseConnect(HCONNECT hConnect);
// USB_ReadConnect and USB_WriteConnect are peer functions
TRANSFERLIB BOOL APIENTRY USB_ReadConnect(HCONNECT hConnect,
DWORD *dwReadDataLen,
LPVOID lpReadDataPtr,
DWORD dwTimeOut);
TRANSFERLIB BOOL APIENTRY USB_WriteConnect(HCONNECT hConnect,
DWORD dwWriteDataLen,
LPVOID lpWriteDataPtr);
// this function will be implemented by the transfer layer, and will not send any message
// to the upper layer (e.g. command layer)
TRANSFERLIB BOOL APIENTRY USB_WriteFile(HCONNECT hConnect,
LPCSTR lpSourceFilePath,
LPCSTR lpDestinationFilePath,
WIN32_FIND_DATA *pFindData,
DWORD dwTimeout);
TRANSFERLIB BOOL APIENTRY SendMultipleFiles_Request(HCONNECT hConnect);
TRANSFERLIB BOOL APIENTRY SendMultipleFiles_Header(HCONNECT hConnect, LPVOID lpData);
TRANSFERLIB BOOL APIENTRY SendMultipleFiles_Check(HCONNECT hConnect, LPVOID lpData);
TRANSFERLIB BOOL APIENTRY SendMultipleFiles_Data(HCONNECT hConnect, LPVOID lpData);
TRANSFERLIB BOOL APIENTRY SendMultipleFiles_Complete(HCONNECT hConnect);

TRANSFERLIB BOOL APIENTRY ReadMulFile_Request(HCONNECT hConnect);
TRANSFERLIB BOOL APIENTRY ReadMulFile_Complete(HCONNECT hConnect);
TRANSFERLIB BOOL APIENTRY ReadMulFile_Parameters(HCONNECT hConnect, char opCode, LPCSTR srcPath, LPCSTR srcName, LPCSTR dstFolder);
TRANSFERLIB BOOL APIENTRY ReadMulFile_Header(HCONNECT hConnect, LPVOID xferBuf);
TRANSFERLIB BOOL APIENTRY ReadMulFile_Check(HCONNECT hConnect, char action);
TRANSFERLIB BOOL APIENTRY ReadMulFile_Data(HCONNECT hConnect, LPVOID xferBuf, DWORD dwReadLen, DWORD *pRealReadLen);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif /* _TRANSFER_H_ */
 
K

kkyy

Unregistered / Unconfirmed
GUEST, unregistred user!
// callback function
typedef void (CALLBACK *NOTIFYPROC)(UINT nNofityMsg, LPARAM lParam);
是吧?
type NOTIFYPROC = procedure(nNofityMsg: Word;
lParam: Integer);
 
K

kkyy

Unregistered / Unconfirmed
GUEST, unregistred user!
也可以:
var NOTIFYPROC : procedure(nNofityMsg: Word;
lParam: Integer);
 
H

hua8hua

Unregistered / Unconfirmed
GUEST, unregistred user!
那我该怎么处理这个USB_InitService(NOTIFYPROC fnNotifyProc);这个函数?
 
C

copy_paste

Unregistered / Unconfirmed
GUEST, unregistred user!
type
TNotifyProc = procedure (nNofityMsg: UINT;
lParam: Integer);
stdcall;
procedure USB_InitService(fnNotifyProc: TNotifyProc): Boolean;
stdcall;
procedure MyNotifyProc(nNofityMsg: UINT;
lParam: Integer);
stdcall;
begin
case nNofityMsg of
...
end;
end;
//call:
USB_InitService(MyNotifyProc);
 
C

copy_paste

Unregistered / Unconfirmed
GUEST, unregistred user!
HCONNECT ==>
type
PConnect = ^TConnect;
TConnect = record
unused: Integer;
end;
HConnect = PTConnect;
 
H

hua8hua

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 
顶部