Hello,
This post is just to find out if the FPC developers would be interested in an updated set of Windows API definitions that, IMO, have a few improvements. For instance, consider the declaration:
function BroadcastSystemMessage
(
{ _in_ } InFlags : DWORD;
{ _inout_opt_ } InoutoptInfo : PDWORD;
{ _in_ } InMsg : DWORD;
{ _in_ } InWparam : ptruint;
{ _in_ } InLparam : ptrint
)
: longint; stdcall; external user32;
{ WARNING: this function is exported without an "A" to indicate Ansi and }
{ with an "A" to also indicate Ansi. They are the same function as }
{ they identify the same entry point. }
{ }
{ IOW, don't assume that calling the function without the "A" at the }
{ end may be calling the "W" version of the function }
{ ALSO: the reason for the existence of an "A"-free names is likely due to }
{ the fact that in Win95 this function did NOT have an "A" to mark it }
{ as Ansi }
{ documented at : }
{ }
{ https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-broadcastsystemmessage }
Note that the parameter disposition is part of its name, i.e, "in", "inout", "inoutopt' and "out", the parameters are stacked. The parameter types are often (not always) Pascal types, e.g, ptruint instead of WPARAM. The result type is always aligned with the function's name beginning. the calling convention is always explicit, the "name" is only stated if for whatever reason the function is exported by a different name. The dll name always refers to a constant, e.g, user32 (instead of a string 'user32')
"in" means a valid value must be passed
"out" means the parameter value will be set/returned
"opt" means the parameter is optional (nil in the case of a pointer)
Parameter "const"ness is not part of the parameter name but, if the parameter is "const" that fact is in the disposition comment that precedes the parameter, e.g.,
function GetPropA
(
{ _in_ } InWnd : HWND;
{ _in_ const } InString : pchar
)
: THANDLE; stdcall; external user32;
Some API definitions have comments and/or warnings about notable characteristics they may have. This is convenient when jumping to a function definition to find out if there are "details" the programmer should be aware of.
Whenever possible the url where the API is fully documented follows the definition.
The parameter dispositions being part of the parameter name is particularly useful due to CODETOOLS, that way when programming, CODETOOLS tells you if the parameter is "in", "out", "opt", etc which is definitely nice to know on the spot.
To give an idea of the differences from current to proposed, consider the definitions of GetClientRect (current definition);
function GetClientRect(hWnd:HWND; lpRect:LPRECT):WINBOOL; external 'user32' name 'GetClientRect';
function GetClientRect(hWnd: HWND; var lpRect: TRect): BOOL; external 'user32' name 'GetClientRect';
Updated definitions:
function GetClientRect
(
{ _in_ } InWnd : HWND;
{ _out_ } OutRect : PRECT
)
: BOOL; stdcall; external user32;
function GetClientRect
(
{ _in_ } InWnd : HWND;
{ _out_ } out OutRect : TRECT
)
: BOOL; stdcall; external user32;
{ documented at : }
{ }
{ https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclientrect }
One of the definitions would be in func.inc, the other in redef.inc. The "Documented at:" part would be in both.
I have roughly 3500 such definitions (they are the definitions I use in my programs, therefore they have been tested) and I would ensure that the updated definitions are functionally equivalent to the current ones.
Also and particularly in the case of NTDLL, I have hundreds of definitions for undocumented functions/procedures. All of them are current and tested. NOTE: much more complete, not to mention current, than the Jwa... definitions.
If there is interest, I would update the necessary files (func.inc, redef.inc for regular win and wince.)
Note: unlike the current definitions in func.inc which use "var' for parameters that are "out", e.g, GetClientRect, which cause warnings about uninitialized data, my definitions use either "out" or a pointer type (the C equivalent definition which is what I normally use.)
Lastly, as previously stated, I have about 3500 such definitions. I don't have the entire Windows API, therefore this offer is for about 3500 definitions (maybe a few more, maybe a few less but definitely not the 13000+ APIs Windows currently supports nor every API that is currently declared in func.inc and redef.inc. (though, I'd try to include as many of those as reasonably possible.)
Comments welcome.