Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.35 KB

TPJCustomConsoleApp-ThreadAttrs.md

File metadata and controls

43 lines (31 loc) · 1.35 KB

ThreadAttrs property

Project: Console Application Runner Classes

Unit: PJConsoleApp

Classes: TPJCustomConsoleApp, TPJConsoleApp

Applies to: ~>3.0

property ThreadAttrs: PSecurityAttributes;

Description

ThreadAttrs specifies the security and inheritance attributes for the console application's primary thread. It determines whether the thread handle can be inherited by child processes. Leaving the property as nil means the thread handle can't be inherited.

Note that the caller is responsible for setting up the structure correctly. The caller need not maintain a copy of the provided structure once the property is set since an internal copy is made.

The property's default value is nil.

To make the primary thread handle inheritable set the bInheritHandle field of the TSecurityAttributes record to True. For example:

var
  App: TPJConsoleApp;
  Attrs: TSecurityAttributes;
begin
  Attrs.nLength := SizeOf(Security);
  Attrs.lpSecurityDescriptor := nil;
  Attrs.bInheritHandle := True;
  App := TPJConsoleApp.Create;
  try
    App.ThreadAttrs := @Attrs;
    ...
  finally
    App.Free;
  end;
end;

The property is public in TPJConsoleApp and protected in TPJCustomConsoleApp.