如何建立多进程呢?请教,在线等! 请大家帮忙了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit MyThreadPro;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) UsedThread: TButton; NoUsedThread: TButton; procedure UsedThreadClick(Sender: TObject); procedure NoUsedThreadClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}function MyThreadFunc(P:pointer):Longint;stdcall;var i:integer; DC:HDC; S:string;begin DC:=GetDC(Form1.Handle); for i:=0 to 100000 do begin S:=Inttostr(i); Textout(DC,10,10,Pchar(S),length(S)); end; ReleaseDC(Form1.Handle,DC);end;procedure TForm1.UsedThreadClick(Sender: TObject);var hThread:Thandle;//定义一个句柄 ThreadID:DWord;begin//创建线程,同时线程函数被调用hthread:=CreateThread(nil,0,@MyThreadfunc,nil,0,ThreadID); if hThread=0 thenmessagebox(Handle,'Didn’t Create a Thread',nil,MB_OK);end;procedure TForm1.NoUsedThreadClick(Sender: TObject);begin MyThreadfunc(nil); //没有创建线程时,直接调用线程函数end;end. unit unit1interfaceuses classes;typeTMyThread1=class(TThread)private{Private declarations}protectedprocedure Execute;overide;end;implementation.......procedure TMyThread1.Execute;begin...{place thread code here}end;end.在execute方法中编写该进程要执行的任务。 Delphi 有自带的例子!!! Delphi目录下Demos\Threads下的工程文件可能对你有用 CreateThread (Form1.Handle, @functionName, functionParm,0 );看Win Api32 SDK 帮助 向access添加数据问题 string和widestring转换丢失数据的问题 大家帮帮忙啊,是个Idhttp发送内容给ASP网页的问题! 在delphi中如何访问共享目录??? 关于一个简单pascal的表的定义问题:急 你觉得女孩的年龄在哪有个坎? 如何在Delphi6中解除对JDK1.2.2的绑定 难道网上没有谁会在delphi中使用spread控件吗 一个很有难度的问题 这样用事务为什么不行? Delphi4如何控制word? 十万火急再加十万火急
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
UsedThread: TButton;
NoUsedThread: TButton;
procedure UsedThreadClick(Sender: TObject);
procedure NoUsedThreadClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}function MyThreadFunc(P:pointer):Longint;stdcall;
var
i:integer;
DC:HDC;
S:string;
begin
DC:=GetDC(Form1.Handle);
for i:=0 to 100000 do begin
S:=Inttostr(i);
Textout(DC,10,10,Pchar(S),length(S));
end;
ReleaseDC(Form1.Handle,DC);
end;procedure TForm1.UsedThreadClick(Sender: TObject);
var
hThread:Thandle;//定义一个句柄
ThreadID:DWord;
begin
//创建线程,同时线程函数被调用
hthread:=CreateThread(nil,0,@MyThreadfunc,nil,0,ThreadID);
if hThread=0 then
messagebox(Handle,'Didn’t Create a Thread',nil,MB_OK);
end;procedure TForm1.NoUsedThreadClick(Sender: TObject);
begin
MyThreadfunc(nil);
//没有创建线程时,直接调用线程函数
end;end.
interface
uses classes;
type
TMyThread1=class(TThread)
private
{Private declarations}
protected
procedure Execute;overide;
end;
implementation
.......procedure TMyThread1.Execute;
begin
...{place thread code here}
end;
end.
在execute方法中编写该进程要执行的任务。
);看Win Api32 SDK 帮助