?? getexitcodethreadu.pas
字號:
unit GetExitCodeThreadU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button_CreateThread: TButton;
Button_GetExitCode: TButton;
procedure Button_CreateThreadClick(Sender: TObject);
procedure Button_GetExitCodeClick(Sender: TObject);
private
public
{ Public declarations }
end;
var
Form1: TForm1;
ThreadHandle: Integer;
implementation
{$R *.DFM}
function ThreadFunction(Info: Pointer): Integer; StdCall
var
Count: Integer; // general loop counter
FormDC: HDC; // holds the form device context
CountStr: string; // holds a string representation of the counter
begin
{retrieve the form device context}
FormDC := GetDC(Form1.Handle);
{display something visual}
for Count := 1 to 1000 do
begin
CountStr := IntToStr(Count);
TextOut(FormDC, 10, 10, Pchar(CountStr), Length(CountStr));
end;
{release the device context and exit the thread}
ReleaseDC(Form1.Handle, FormDC);
ExitThread(4);
end;
procedure TForm1.Button_CreateThreadClick(Sender: TObject);
var
ThreadId: DWORD; // holds the thread identifier
begin
{create and execute a thread}
ThreadHandle := CreateThread(nil, 0, @ThreadFunction, nil, 0, ThreadId);
if (ThreadHandle = 0) then
MessageBox(Handle, 'No Thread Created', nil, MB_OK);
end;
procedure TForm1.Button_GetExitCodeClick(Sender: TObject);
var
ExitCode: DWORD; // holds the thread exit code
begin
{retrieve and display the thread's exit code}
GetExitCodeThread(ThreadHandle, ExitCode);
ShowMessage('The exit code is ' + IntToStr(ExitCode));
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -