yoy.be "Why-o-Why"

2010 ...

januari (4) februari (6) maart (5) april (2) mei (2) juni juli augustus (2) september oktober (5) november (2) december (3)

How to set the thread display name for the thread list debug window

2010-11-05 00:25  i2945  delphi  [permalink]

This little trick appears to work in the Delphi debugger also! Use this code to set the debug display name for the current thread:

interface


function IsDebuggerPresent: BOOL; stdcall;

implementation


uses
Windows;


function
IsDebuggerPresent; external 'kernel32.dll';

procedure
SetThreadName(ThreadDisplayName:AnsiString);
var
  ThreadInfo:record
    dwType:LongWord;
    szName:PAnsiChar;
    dwThreadID:LongWord;
    dwFlags:LongWord;
  end;
begin
if IsDebuggerPresent then
begin
  ThreadInfo.dwType:=$1000;
  ThreadInfo.szName:=PAnsiChar(ThreadDisplayName);
  ThreadInfo.dwThreadID:=LongWord(-1);//calling thread
  ThreadInfo.dwFlags:=0;
  try
    RaiseException($406D1388,0,SizeOf(ThreadInfo) div SizeOf(LongWord),@ThreadInfo);
  except
    //
  end;
end;
end;

twitter reddit linkedin facebook

How to set the thread display name for the thread list debug window

2010-11-08 21:58  r1607  delphi  [permalink]

How to set the thread display name for the thread list debug window

 See also http://nldelphi.com/Forum/showthread.php?t=36655


twitter reddit linkedin facebook