大家帮我看看c++ bulider 写的多线程,在delphi中怎么写??

luckyboy21c 2003-02-24 11:04:56
大家帮我看看c++ bulider 写的多线程,在delphi中怎么写??
unit2.h文件
//---------------------------------------------------------------------------

#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
//---------------------------------------------------------------------------
class TScanThread : public TThread
{
private:
protected:
void __fastcall Execute();
public:
__fastcall TScanThread(bool CreateSuspended);
};
//---------------------------------------------------------------------------
#endif
...全文
32 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xinghf 2003-02-24
  • 打赏
  • 举报
回复
gz
ehom 2003-02-24
  • 打赏
  • 举报
回复
大家都是基于VCL,既然实现方法也是一样的,不懂Object Pascal的语法吗?

TScanThread = class(TThread)
protected
procedure Execute;override;
public
procedure TScanThread(CreateSuspended:Bool);
end;

var domode:integer = 0;

procedure TScanThread.Execute;
var
sfile,ofile:array[0..255] of Char;
ofps:Integer;
begin
if domode=0 then
ofps := scanSavetofile(ofile)
else
ofps := scanEditfile(sfile, ofile);
if ofps > 0 then
Application.MessageBox('scanSavetofile/scanEditfile done.', nil, MB_OK);
end;
soloplayer 2003-02-24
  • 打赏
  • 举报
回复
unit Unit2;

interface

uses
Classes;

type
test = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
constructor create(CreateSuspended:boolean);
end;

implementation

{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,

Synchronize(UpdateCaption);

and UpdateCaption could look like,

procedure test.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }

{ test }
constructor test.create(CreateSuspended:boolean);
begin
inherited create(createsuspended);
end;

procedure test.Execute;
begin
{ Place thread code here }
///这里写你的代码;
end;

end.
outer2000 2003-02-24
  • 打赏
  • 举报
回复
unit Unit2;

interface

uses
Classes;

type
test = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;

implementation

{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,

Synchronize(UpdateCaption);

and UpdateCaption could look like,

procedure test.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }

{ test }

procedure test.Execute;
begin
{ Place thread code here }
///这里写你的代码;
end;

end.
luckyboy21c 2003-02-24
  • 打赏
  • 举报
回复
unit2.cpp文件
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
#pragma package(smart_init)

#include "hniscan.h"

//---------------------------------------------------------------------------

// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall TScanThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------

int domode = 0;

__fastcall TScanThread::TScanThread(bool CreateSuspended)
: TThread(CreateSuspended)
{
}

//---------------------------------------------------------------------------
void __fastcall TScanThread::Execute()
{
extern char sfile[256], ofile[256];
extern int ofps;

if (domode == 0)
ofps = scanSavetofile(ofile);
else
ofps = scanEditfile(sfile, ofile);
if (ofps > 0)
{
Application->MessageBox(
"scanSavetofile/scanEditfile done.", NULL, MB_OK);
}
}

//---------------------------------------------------------------------------
庆祝0101 2003-02-24
  • 打赏
  • 举报
回复
结贴,给分

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧