PeterPanettone 167 Posted 19 hours ago (edited) 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 19 hours ago by PeterPanettone Share this post Link to post
Anders Melander 1986 Posted 16 hours ago 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 167 Posted 16 hours ago Doesn't Winapi.Windows pull this constant from Winapi.WinNT.pas? But Winapi.WinNT.pas is also missing. Share this post Link to post
DelphiUdIT 229 Posted 15 hours ago (edited) @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 15 hours ago by DelphiUdIT Share this post Link to post
PeterPanettone 167 Posted 14 hours ago 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
PeterPanettone 167 Posted 14 hours ago (edited) 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 14 hours ago by PeterPanettone Share this post Link to post
Remy Lebeau 1581 Posted 8 hours ago (edited) 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 8 hours ago by Remy Lebeau Share this post Link to post
PeterPanettone 167 Posted 6 hours ago (edited) 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: The code compiles without errors. Edited 6 hours ago by PeterPanettone Share this post Link to post
Kas Ob. 136 Posted 4 hours ago 1 hour ago, PeterPanettone said: Thank you for your answer. However, the Delphi 12.2 compiler seems to accept this as a conditional compilation: 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
DelphiUdIT 229 Posted 4 hours ago 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" ... Bye Share this post Link to post