unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function CheckLcdStr(LCDStr:String;ch:Integer):String;
var
I:Integer;
CallID : array[0..47] of char;
TempLCDStr : String;
begin
StrCopy(CallID,PChar(Copy(LCDStr,1,46)));
Result:='';
TempLCDStr:=LowerCase(LCDStr);
if pos('from',TempLCDStr)>0 then
begin
for I:=0 to 47do
begin
if CallID in ['0'..'9'] then
begin
Result:=Result+ String(CallID);
end;
if (CallID in [' ']) and (Result<>'') then
break;
end;
if Result='' then
Exit;
end;
end;
function ThreadFunc3(pointer):LongInt;stdcall;
var
a:String;
l:integer;
begin
for l:=0 to 10000000do
begin
a:=inttostr(l);
end;
end;
function ThreadFunc5(pointer):LongInt;stdcall;
var
b:String;
l:integer;
begin
for l:=0 to 10000000do
begin
b:=inttostr(l);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
hThread:THandle;
ThreadIDWORD;
i:integer;
begin
hthread:=CreateThread(nil,
0,
@THreadFunc3,
nil,
0,
ThreadID);
if hthread=0 then
MessageBox(Handle,'NO Thread',nil,MB_OK)
else
closehandle(hthread);
hthread:=CreateThread(nil,
0,
@THreadFunc5,
nil,
0,
ThreadID);
if hthread=0 then
MessageBox(Handle,'NO Thread',nil,MB_OK)
else
closehandle(hthread);
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function CheckLcdStr(LCDStr:String;ch:Integer):String;
var
I:Integer;
CallID : array[0..47] of char;
TempLCDStr : String;
begin
StrCopy(CallID,PChar(Copy(LCDStr,1,46)));
Result:='';
TempLCDStr:=LowerCase(LCDStr);
if pos('from',TempLCDStr)>0 then
begin
for I:=0 to 47do
begin
if CallID in ['0'..'9'] then
begin
Result:=Result+ String(CallID);
end;
if (CallID in [' ']) and (Result<>'') then
break;
end;
if Result='' then
Exit;
end;
end;
function ThreadFunc3(pointer):LongInt;stdcall;
var
a:String;
l:integer;
begin
for l:=0 to 10000000do
begin
a:=inttostr(l);
sleep(1);//增加--------------------------
end;
end;
function ThreadFunc5(pointer):LongInt;stdcall;
var
b:String;
l:integer;
begin
for l:=0 to 10000000do
begin
b:=inttostr(l);
sleep(1);//增加--------------------------
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
hThread:THandle;
ThreadIDWORD;
i:integer;
begin
hthread:=CreateThread(nil,
0,
@THreadFunc3,
nil,
0,
ThreadID);
if hthread=0 then
MessageBox(Handle,'NO Thread',nil,MB_OK)
else
closehandle(hthread);
hthread:=CreateThread(nil,
0,
@THreadFunc5,
nil,
0,
ThreadID);
if hthread=0 then
MessageBox(Handle,'NO Thread',nil,MB_OK)
else
closehandle(hthread);
function IntToStr(Value: Integer): string;
// FmtStr(Result, '%d', [Value]);
asm
PUSH ESI
MOV ESI, ESP
SUB ESP, 16
XOR ECX, ECX // base: 0 for signed decimal
PUSH EDX // result ptr
XOR EDX, EDX // zero filled field width: 0 for no leading zeros
CALL CvtInt
MOV EDX, ESI
POP EAX // result ptr
CALL System.@LStrFromPCharLen
ADD ESP, 16
POP ESI
end;
看看函数再说吧