请问这个vc的程序如何能转成delphi(88分)(88分)

  • 主题发起人 主题发起人 xiaer_wang
  • 开始时间 开始时间
X

xiaer_wang

Unregistered / Unconfirmed
GUEST, unregistred user!
int CHKVisionDlg::OnDataReady(UINT channelNum, INT lparam)<br>{<br>&nbsp; &nbsp; &nbsp; &nbsp; extern unsigned char StreamBuf[500000];<br> ULONG length = 500000;<br> int frameType;<br> int status;<br> status = ReadStreamData(ChannelHandle[channelNum], StreamBuf, &nbsp;&amp;length, &amp;frameType);<br> if(frameType &gt; 0) {<br> if(frameType == PktSysHeader){<br> // store the file header<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memcpy(FileHeader[channelNum], StreamBuf, length);<br> FileHeaderLen = length;<br> }<br><br>我的Vc不照,不知道这段程序表达了什么意思。唉<br>请高手能不能帮忙看看程序,帮我转成delphi的<br>谢谢<br>
 
function &nbsp;OnDataReady(channelNum:word;lparam:integer):integer;<br>var<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StreamBuf:packed array [0..500000] of byte;external;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length :dword;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frameType,status:integer;<br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length:=500000;<br><br> status:=ReadStreamData(ChannelHandle[channelNum], StreamBuf, &nbsp;length, frameType);<br> if (frameType &gt; 0) then<br><br>// { : begin???你的代码没有匹配的end<br><br> if (frameType = PktSysHeader) then // store the file header<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;move(FileHeader[channelNum], StreamBuf, length);<br> &nbsp; &nbsp;FileHeaderLen:=length;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>end;<br>&nbsp;<br>
 
to wql:<br><br>不行啊<br>当我执行到status:=ReadStreamData(ChannelHandle[channelNum], StreamBuf, &nbsp;length, frameType);<br>就会报错。<br>我这个函数ReadStreamData是来自一个vc的动态链接库<br>函数原型:Int ReadStreamData(Handle hChannelHandle,void *DataBuf,Dword *Length,int *Frametype);<br>我的转换是:function ReadStreamData(hChannelHandle: THandle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataBuf: &nbsp;Array of byte;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var length:Dword;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Frametype:Integer): integer; cdecl &nbsp;{$IFDEF WIN32} stdcall {$ENDIF};<br>是不是我转换出了问题???<br><br>请你帮忙看看。谢谢
 
array好像是非要指定范围的吧,像array[0..10000] of byte
 
<br>你怎么不早说:<br><br>函数原型:Int ReadStreamData(Handle hChannelHandle,void *DataBuf,Dword *Length,int *Frametype);<br>Function ReadStreamData(hChannelHandle: THandle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataBuf: &nbsp;Pointer;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length:^Dword;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Frametype:^Integer):integer;stdcall;<br><br>var<br>&nbsp; len &nbsp;: ^DWord;<br>&nbsp; Frm &nbsp;: ^Integer;<br><br>len:=@length;<br>Frm:=@frameType;<br>status:=ReadStreamData(ChannelHandle[channelNum], @StreamBuf, len, frm);<br>
 
to wql<br>&nbsp; 哎,还是不对。还得麻烦你帮我看看<br>Function ReadStreamData(hChannelHandle: THandle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataBuf: &nbsp;Pointer;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length:^Dword;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Frametype:^Integer):integer;stdcall;<br><br><br>这样写:会出编译错误 &nbsp;Identifier expected but '^' found
 
Function &nbsp;ReadStreamData(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hChannelHandle:THandle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataBuf:Pointer;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _len:^Dword;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Frametype:^Integer):integer;stdcall;<br><br>
 
type Plength=^Dword;<br>&nbsp; &nbsp; &nbsp;Pinteger=^integer;<br>function ReadStreamData(hChannelHandle: THandle; DataBuf: pointer; len:Plength;Frametype:Pinteger): integer;<br>var<br>length;integer;<br>frametype:integer;<br>readstreamdata((hChannelHandle, DataBuf, @length,@Frametype);
 
只是把^Dword 变为Plength罢了!<br>
 
谢谢<br>编译能通过了
 
多人接受答案了。
 
后退
顶部