unit8.pas

来自「学校短信息系统 采用华域科技的SzgmtSms 通讯模块」· PAS 代码 · 共 72 行

PAS
72
字号
unit Unit8;

interface

uses
  Classes {$IFDEF MSWINDOWS} , Windows {$ENDIF};

type
  testth = class(TThread)
  private
    procedure SetName;
  protected
    procedure Execute; override;
  end;

implementation
uses main;
{ 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 testth.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{$IFDEF MSWINDOWS}
type
  TThreadNameInfo = record
    FType: LongWord;     // must be 0x1000
    FName: PChar;        // pointer to name (in user address space)
    FThreadID: LongWord; // thread ID (-1 indicates caller thread)
    FFlags: LongWord;    // reserved for future use, must be zero
  end;
{$ENDIF}

{ testth }

procedure testth.SetName;
{$IFDEF MSWINDOWS}
var
  ThreadNameInfo: TThreadNameInfo;
{$ENDIF}
begin
{$IFDEF MSWINDOWS}
  ThreadNameInfo.FType := $1000;
  ThreadNameInfo.FName := 'myth1';
  ThreadNameInfo.FThreadID := $FFFFFFFF;
  ThreadNameInfo.FFlags := 0;

  try
    RaiseException( $406D1388, 0, sizeof(ThreadNameInfo) div sizeof(LongWord), @ThreadNameInfo );
  except
  end;
{$ENDIF}
end;

procedure testth.Execute;
var
handle:hwnd;
begin
  SetName;
  { Place thread code here }
  mainform.Caption:='hello';
  windows.messagebox(Handle,'test thread!',nil,MB_OK);
end;

end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?