C语言中的一跳命令转Delphi语法。(200分)

  • 主题发起人 主题发起人 sm2006
  • 开始时间 开始时间
S

sm2006

Unregistered / Unconfirmed
GUEST, unregistred user!
typedef void (FAR WINAPI *DOWNLOADMSGPROC)(LPTSTR str,BOOL newline);<br><br>This function type is used by some program downloading procedures to offer the option of reporting a status message.<br><br>Arguments<br><br>str Message string.<br>newline Indicates if a new line should be added by the called procedure.<br><br>Return Value<br><br>None.<br>请教高手,如何把typedef void (FAR WINAPI *DOWNLOADMSGPROC)(LPTSTR str,BOOL newline);写成Delphi语法。先谢了。
 
procedure(str : pchar; newline : boolean) of object;
 
type<br> &nbsp;TDownloadMsgProc = procedure(str: PChar; NewLine: Boolean); stdcall;<br><br>函数指针,楼上写的是什么?
 
那么:<br>typedef long &nbsp;(FAR WINAPI *DOWNLOADGETPROC)(long nIndex,LPTSTR lpszBuffer,long nMaxLength);<br>是不是=<br>type<br> &nbsp;TDownloadGetProc = Function(nIndex: Int64; lpszBuffer: PChar;nMaxLength:Int64):int64; stdcall;<br>谢谢errorcode <br>还有:<br>long &nbsp;PmacDownloadA(DWORD dwDevice, DOWNLOADMSGPROC msgp, DOWNLOADGETPROC getp, DOWNLOADPROGRESS pprg, PCHAR filename, BOOL macro, BOOL map, BOOL log, BOOL dnld);<br><br>This function takes an ASCII file, processes it, and downloads it from the PC to the PMAC. &nbsp;Processing includes MACRO parsing and compiling PLCs, for example. &nbsp;This function can generate several residual files, as described in the table below. ....<br>我已经改为Delphi语法:<br> &nbsp; function &nbsp; PmacDownloadA(dwDevice:DWORD;msgp:DOWNLOADMSGPROC;getp: DOWNLOADGETPROC; pprg:DOWNLOADPROGRESS; filename:PCHAR; macro,map,log,dnld:boolean):Int64;stdcall;external 'PComm32.dll';<br><br>请问errorcode大侠:在调用PmacDownloadA函数时,参数表中的msgp,getp,pprg用什么方式的数据项,谢谢。
 
Delphi就几个类型函数指针,of object是Delphi的事件指针,一般我们写的onFormCreate之类的。还有就是Windows的,一般就是用于回调函数。<br><br>函数指针就是你再写一个函数,将函数名称传递给那个调用者,如:<br>function MyDownloadProc(Index: DWORD; buf: PChar; len: DWORD): DWORD; stdcall;<br>begin<br> &nbsp;Result := 0;<br> &nbsp;....<br>end;<br><br>abcCallFunc(@MyDownloadProc, ....);<br><br>另:long=&gt;DWORD, Cardinal<br><br>不多说了,这些是一些基础知识,很容易找到的。
 
虽然没有完全明白,还是谢谢errorcode大侠
 
后退
顶部