Jump to content
PeterPanettone

Winapi.Windows.PROCESS_QUERY_LIMITED_INFORMATION not found

Recommended Posts

In my Delphi 12.2 Winapi.Windows.pas unit in Windows 11, the declaration for PROCESS_QUERY_LIMITED_INFORMATION ($1000) constant is missing. Does this mean that my Winapi.Windows.pas unit is potentially corrupted?

Edited by PeterPanettone

Share this post


Link to post
2 hours ago, PeterPanettone said:

Does this mean that my Winapi.Windows.pas unit is potentially corrupted?

Corrupted? Because of a missing declaration?

 

There are lots of stuff missing, at any given time, since new values, structures, and functions gets added to the Win32 API all the time and Embarcadero can't keep up.

 

PROCESS_QUERY_LIMITED_INFORMATION has been missing for ages. Just declare it locally and move on.

Share this post


Link to post

@PeterPanettone

If something of WinApi is missing, you can look at this and download the WINMD from getit: https://docwiki.embarcadero.com/RADStudio/Athens/en/What's_New#WinAPI_Delphi_Headers_from_WinMD_metadata

 

Like they told,

Quote

These new headers are much more extensive, covering all recent APIs compared to the set available in the core RTL.

Bye

 

P.S.:I use some of those headers to include some functionalities missing in Embarcadero WinApi.

Edited by DelphiUdIT

Share this post


Link to post

Hello DelphiUdIT,

Thanks for the hint. How would you reference PROCESS_QUERY_LIMITED_INFORMATION from WinMD?

 

I need to use it in this context:

  hProcess := Winapi.Windows.OpenProcess(
    PROCESS_QUERY_LIMITED_INFORMATION, // cannot be retrieved from Winapi.Windows
    False,
    ProcessID
  );

So I implemented it as  a local constant:

const
  {$IFNDEF PROCESS_QUERY_LIMITED_INFORMATION}
  PROCESS_QUERY_LIMITED_INFORMATION = $1000;
  {$ENDIF}

 

Share this post


Link to post

Ah, I've found it here:

 

C:\Users\<username>\Documents\Embarcadero\Studio\23.0\CatalogRepository\WindowsAPIfromWinMD-1.0\Windows.System.Threading.pas

 

Very nice!

 

Unfortunately, the GetIt installer does not add WindowsAPIfromWinMD-1.0 to the Library Path.

Edited by PeterPanettone

Share this post


Link to post
6 hours ago, PeterPanettone said:

So I implemented it as  a local constant:


const
  {$IFNDEF PROCESS_QUERY_LIMITED_INFORMATION}
  PROCESS_QUERY_LIMITED_INFORMATION = $1000;
  {$ENDIF}

 

That won't work, as PROCESS_QUERY_LIMITED_INFORMATION is not a conditional you can test with {$IFNDEF}. Use {$IF NOT DECLARED} instead:

{$IF NOT DECLARED(PROCESS_QUERY_LIMITED_INFORMATION)}
const
  PROCESS_QUERY_LIMITED_INFORMATION = $1000;
{$IFEND} 

 

Edited by Remy Lebeau

Share this post


Link to post
2 hours ago, Remy Lebeau said:

That won't work, as PROCESS_QUERY_LIMITED_INFORMATION is not a conditional you can test with {$IFNDEF}. Use {$IF NOT DECLARED} instead:


{$IF NOT DECLARED(PROCESS_QUERY_LIMITED_INFORMATION)}
const
  PROCESS_QUERY_LIMITED_INFORMATION = $1000;
{$IFEND} 

 

Hello Remy Lebeau,

 

Thank you for your answer. However, the Delphi 12.2 compiler seems to accept this as a conditional compilation:

 

image.thumb.png.2b25d550a944bb2c8abb54d17e3608ac.png

 

The code compiles without errors.

Edited by PeterPanettone

Share this post


Link to post
1 hour ago, PeterPanettone said:

Thank you for your answer. However, the Delphi 12.2 compiler seems to accept this as a conditional compilation:

 

image.thumb.png.2b25d550a944bb2c8abb54d17e3608ac.png

 

The code compiles without errors.

Edited 57 minutes ago by PeterPanettone

No, that is misuse between declaration and definition, use what Remy suggested.

 

IFDEF/IFNDEF about definition, literally defined, these are not for the code but for the compiler variables.

DECLARED()/NOT DECLARED() these about your code, namely anything that can be declared like consts, records, classes ....

 

It compile in your case because there is no defined directives (compiler directive) under that name.

 

Example:

var
  i: Integer;
  B: Integer;      // comment this and the compilation will fail
{$IF NOT DECLARED(B)}
  This should cause an error only if you comment or remove B from variables
{$IFEND}

 

Share this post


Link to post
10 hours ago, PeterPanettone said:

Unfortunately, the GetIt installer does not add WindowsAPIfromWinMD-1.0 to the Library Path.

That's fine with me, because then I copy all the units used as "uses" (NOT COMPONENTS) into the $BDSUSERDIR\Imports folder (in this case the WINMD folder)
And in the library paths I add that path (which is specific to the platform). In this way I have a single point (I repeat only for the uses, i.e. those units that represent a stand-alone functionality) under which there are all the "utilities" and that will be copied and maintained for each version of RAD STUDIO. I still have some files from almost twenty years ago that I still use (rarely, only for maintenance of old code ... with the new RAD).

"It's an ill wind that blows nobody any good" ... :classic_biggrin:

 

Bye

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×