WinApi32 declarations archive (x86 & x64): public project

Post your tools and samples or ask for them.
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 400
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

WinApi32 declarations archive (x86 & x64): public project

Post by Dave Rabelink » 03 Mar 2017, 20:34

There are quite some libraries with Windows API declarations published in the past on the old and new forum and many samples
are created which uses Windows API.

One started public project in the past was to collect all those declarations (dll function definitions) and constants and place them in a downloadable package: WinApi32.zip

This archive contains now many WinAPI functions and constants.

With the new TD UNICODE versions, the archive was updated to include some UNICODE specific functions (W-functions).
But unfortunately, this archive is not maintained many years in a central place.

I would like to start again with collecting all those handy WinAPI functions and constants and try to enhance the current set of declarations.
Many of us have developed applications and used API functionalities which are not present in the public archive and many UNICODE versions are only locally in use.
And to avoid that we all invent the wheel multiple times, it would be better if there is one central place to get a full set of ANSI and UNICODE declarations to be used as reference or directly in your own projects.

I wanted to create one archive with both ANSI and UNICODE declarations and not to split them up in separate ones.
The original old Win32Api archive and the unicode version from SalExtension was the basis for this new archive.
I also integrated declarations from a few samples.

The archive contains these files:

- WinApi32A.apl -> Main library for all ANSI WinApi declarations, it includes all the needed libs
- WinApi32W.apl -> Main library for all UNICODE WinApi declarations, it includes all the needed libs
- WinApi32_Functions_A.apl -> ANSI specific function declarations (A)
- WinApi32_Functions_W.apl -> UNICODE specific function declarations (W)
- WinApi32_Functions_x64.apl -> x64 specific function declarations (for 64 bit TD versions)
- WinApi32_Functions.apl -> Shared function declarations, not specific to ANSI or UNICODE
- WinApi32_Constants.apl -> Shared constants declarations, containing ANSI and UNICODE specific declarations
- WinApi32_CommonCtrlConstants.apl -> Shared common control constant declarations, containing ANSI and UNICODE specific declarations

Every file has it's own version info, so when changes are done it is added as history info in the file
The complete package has main version. When one of the files in the archive is changed, the version of the file but also the version of the package is increased.

To be source-compatible with TD versions starting from TD 1.5.1:
The common and ANSI (A) specific files are saved in TD 1.5.1 text format.
The UNICODE (W) specific files are saved in TD 5.1 text format.
The x64 specific files are saved in TD 7.0 text format.

Functions which are explicitly used for ANSI (A) or UNICODE (W) are saved in their separate libraries.
Many functions are common, so not specific A or W and they are in common libraries.

So when you need only UNICODE declarations (and all the rest not specific for UNICODE) you can use WinApi32W.apl
For ANSI (and the rest not specific for ANSI) you can use WinApi32A.apl.


As a start, the first version of the package is created . The latest and older versions will be placed in the TD Sample Vault here:

http://samples.tdcommunity.net/index ... =WinApi32/


I would like to ask developers here to participate in enhancing the WinApi Declaration archive.
There are probably many used WinApi functionalities out there which are not yet part of this archive.
When this is the case, please send changes/additions to me so I can combine the changes and create a new version of the package.
(probably best to only send me a file with the changed/added declarations so it is clear what to change in the archive.)
All changes will be added to the revision histories. Then the new archive is uploaded to the location mentioned above.

When current declarations are not correct, please report this.

By keeping the package up-to-date we will have a usable set of declarations ready to use in our projects. We all benefit.
It would be great if this combined effort will result in a comprehensive source for reference.

If you have suggestions, please share this here in this thread.

For additions/changes to WinApi32 declaration libraries, please send the file(s) to my personal email address:

daverabelink@xs4all.nl
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 400
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: WinApi32 declarations archive (x86 & x64): public project

Post by Dave Rabelink » 03 Mar 2017, 20:35

Now TD 7.0 is here, new x64 specific API's can be used.
Both on x86 and x64 TD versions, these new external function datatypes are available:

Code: Select all

    Number: LONGLONG
    Number: ULONGLONG
    Receive Number: LPLONGLONG
    Receive Number: LPULONGLONG


But we have to be aware that TD 7.0 (x64) requires now the correct datatype declarations to work correctly.
Based on the datatype and TD bitness, TD will use 32bit or 64bit sizes.

Some declarations in the WinApi32 archive do have incorrect assigned datatypes . They will work on 32 bit TD versions and have been working for years.
But when porting to TD x64, these API functions will not work anymore and will fail. Result can be crashes or incorrect values passed or received.

Mainly the rule is:
The declaration should exactly match the description on MSDN.
When the API function complies to the exact datatype, the function will work both on x86 and x64.

To keep the WinApi archive usable on x86 and x64, it would be nice to change incorrect declarations to the correct types.
Also to add x64 specific functions.

A new library is added to the archive:
WinApi32_Functions_x64.apl

It contains specific x64 API declarations, which can only be used by TD x64 versions.
(it is saved in TD 7.0 text format)

When you find in your projects issues with existing API functions on x64 and have the correct declarations tested, please post the changes here or send it by email.
Also new API declarations are welcome.


To start, here is now a new version, v1.10.
It contains already some changes and additions.

Code: Select all

    VERSION 1.10
        - NEW: WinApi32_Functions_x64.apl, API's specially for x64 TD versions:
          Added USER32.DLL    -> GetWindowLongPtrA, GetWindowLongPtrW, SetWindowLongPtrA, SetWindowLongPtrW
                   -> SetClassLongPtrA, SetClassLongPtrW, GetClassLongPtrA, GetClassLongPtrW
          Added SHLWAPI.DLL    -> StrFormatByteSize64A, StrFormatByteSizeW
        - The following functions have been changed to be compatible with x64:
          GetProcAddress, GetModuleHandleA, GetModuleHandleW, LoadLibraryExA, FreeLibrary, RegCloseKey, RegFlushKey
          GetThreadLocale, BeginPaint, EnumWindows, EnumThreadWindows, EnumChildWindows, GetWindow, CallWindowProcW
          CallWindowProcA, DefWindowProcA, DefWindowProcW, DefDlgProcA, DefDlgProcW, DispatchMessageA, DispatchMessageW
          GetClassInfoA, GetClassInfoW, LoadStringW, LoadIconA, LoadCursorA, LoadCursorW, LoadCursorFromFileW
          LoadCursorFromFileA, PostThreadMessageW, PostThreadMessageA, SendMessageA, SendMessageW
          SetWindowsHookExA, SetWindowsHookExW


http://samples.tdcommunity.net/index ... =WinApi32/
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “Tools & Samples”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests