I want a nice convenient name to appear in the thread list window, and in the Delphi 6 IDE. I found the code below on the Internet for this in Delphi 6, since, as far as I know, this version does not have SetThreadName () initially. I call it from my Execute () method. I know what this is called because the IDE appears when an exception occurs. However, when I look in the list of threads (Ctrl + Alt + T), I do not see the name that I gave. I just see the regular columns Id, State, Status and Location Thread, nothing more.
What do I need to do differently to get stream names? Also, does anyone have an idea on how to stop the IDE from pausing a RaiseException string? I have many threads in the program, and it is annoying when the IDE appears every time every time I run the program.
I know that I can disconnect the IDE from stopping in Delphi Exceptions, but I want it to be normal, and I would prefer not to switch this every time a new set of threads is created.
Delphi named threads - what is it?
procedure SetThreadName_delphi(const Name: string); type TThreadNameInfo = record RecType: LongWord; Name: PChar; ThreadID: LongWord; Flags: LongWord; end; var info:TThreadNameInfo; begin // This code is extremely strange, but it the documented way of doing it! info.RecType := $1000; info.Name := PChar(Name); info.ThreadID := $FFFFFFFF; info.Flags := 0; try RaiseException($406D1388, 0, SizeOf(info) div SizeOf(LongWord), PDWord(@info)); except end; end;
Robert Oschler
source share