Question

why this not working ??

with Win32.Winbase; use Win32.Winbase;
with Win32; use type Win32.BOOL;
with Win32.Winnt; use type Win32.Winnt.pHandle;

procedure Welcome is

   Startup_Info      : aliased STARTUPINFO;
   SecurityAttribute : aliased PSECURITY_ATTRIBUTES;

begin

   Startup_Info.dwFlags       := 123;  -- OK

   SecurityAttributes.nLength := 123;  -- ERROR 

end Welcome;
Was it helpful?

Solution

Because PSECURITY_ATTRIBUTES is an access (pointer) type and you haven't allocated an instance of it:

type PSECURITY_ATTRIBUTES is access all SECURITY_ATTRIBUTES;

So you have to allocate an instance of it first:

SecurityAttributes  : PSECURITY_ATTRIBUTES := new SECURITY_ATTRIBUTES;

(Since it's a pointer type, you don't need "aliased".)

Now you can assign to it:

SecurityAttributes.nLength  :=   123;

Alternatively, if SecurityAttributes were declared aliased of type SECURITY_ATTRIBUTES, then your original assignment would have worked. Going by the name, I strongly suspect the leading 'P' is intended to indicate the type is a pointer type.

This has not been compiled, I'm going by an on-line source code listing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top