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: 3352
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

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

Post by Dave Rabelink » 16 May 2013, 13:10

I have uploaded a new version with some additional declarations, v1.06

Code: Select all

    - Added KERNEL32.DLL -> GetUserDefaultUILanguage, GetSystemDefaultUILanguage,
                            GetSystemDEPPolicy, GetProcessDEPPolicy, SetProcessDEPPolicy
    - Added SHELL32.DLL -> SHBrowseForFolderW, SHGetPathFromIDListW
    - Added SEE_* constants (for ShellExecuteEx)
    - Added DEP_* constants and DEP process constants (for DEPPolicy functions)
    - Added missing BIF_* constants (for Shell browse for folder)
https://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

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

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

Post by Dave Rabelink » 03 Jun 2013, 14:20

New version, v1.07

Code: Select all

   - Added KERNEL32.DLL -> LoadLibraryExW, LoadLibraryExA, GetProcessId, GetActiveProcessorCount (Win7), IsWow64Process
   - Added Load library EX flag constants
https://samples.tdcommunity.net/index ... =WinApi32/

When calling WinApi functions from your application (or any other external function) you might want to be sure that the function
exists on the system the application is running.

Use this WIKI tip to check at runtime if a specific function is present before calling it and optionally execute alternative actions:

Check existence of dll functions at runtime
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: 3352
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

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

Post by Dave Rabelink » 10 Jun 2013, 22:17

New version, v1.08

Code: Select all

    - Added KERNEL32.DLL -> SystemTimeToFileTime, CompareFileTime, DosDateTimeToFileTime, GetSystemTimeAsFileTime, GetSystemTimes,
             SetDllDirectoryA, FlushFileBuffers, GetBinaryTypeA, GetCompressedFileSizeA, GetFileType, ReplaceFileA,
             SearchPathA, Wow64DisableWow64FsRedirection, Wow64EnableWow64FsRedirection, Wow64RevertWow64FsRedirection
    - Added KERNEL32.DLL -> SetDllDirectoryW, GetBinaryTypeW, GetCompressedFileSizeW, GetLongPathNameW, ReplaceFileW, SearchPathW
    - Added KERNEL32.DLL -> Alternative versions of FileTimeToSystemTime, GetFileTime (commented in code)
    - Added ADVAPI32.DLL -> EncryptFileA, DecryptFileA, FileEncryptionStatusA
    - Added ADVAPI32.DLL -> EncryptFileW, DecryptFileW, EncryptionDisable, FileEncryptionStatusW
    - Added MSVCRT.DLL -> toupper
    - Added USER32.DLL -> IsCharAlphaA, IsCharAlphaNumericA, IsCharLowerA, IsCharUpperA, AnimateWindow, GetAncestor, GetShellWindow
    - Added USER32.DLL -> IsCharAlphaW, IsCharAlphaNumericW, IsCharLowerW, IsCharUpperW
    - Added GDI32.DLL -> Arc, AngleArc, ArcTo, GetArcDirection, PolyBezier, PolyBezierTo, PolyDraw, PolyLine, PolyLineTo, PolyPolyLine
                         SetArcDirection, AddFontResourceA, GetTextAlign, GetTextColor, SetTextJustification, SetTextCharacterExtra
          GetTextCharacterExtra, GetNearestColor
    - Added GDI32.DLL -> AddFontResourceW
    - Added AnimateWindow AW_* flags, GetAncestor GA_* flags
    - Changed KERNEL32.DLL -> FileTimeToSystemTime, GetFileTime, SetLocalTime, SetTimeZoneInformation return now BOOL instead of void
    - Cleaned up sources: removed many documentation descriptions. They are mostly outdated. Use Internet MSDN to get info
https://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

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

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

Post by Dave Rabelink » 03 Oct 2014, 09:54

New version, v1.09

Code: Select all

    - Added MPR.DLL -> WNetCloseEnum, WNetEnumResourceA, WNetOpenEnumA, WNetAddConnection2A
    - Added MPR.DLL -> WNetAddConnection2W, WNetEnumResourceW, WNetOpenEnumW
    - Added USER32.DLL -> RealChildWindowFromPoint, CreateIconFromResource, CreateDialogParamA, DialogBoxParamA,
           RegisterPowerSettingNotification, UnregisterPowerSettingNotification
    - Added KERNEL32.DLL -> GetLogicalDriveStringsW
    - Added GDI32.DLL -> CreateBitmapIndirect, CreateDIBitmap
    - Added MSVCRT.DLL -> sprintf
    - Added RPCRT4.DLL -> UuidFromStringW, UuidToStringW, RpcStringFreeW
    - Added RPCRT4.DLL -> UuidCreate, UuidFromStringA, UuidToStringA, RpcStringFreeA
    - Added RESOURCE for WNet constants
    - Added several missing WM messages
    - Added constants for POWERBROADCAST msg
    - Added constants ERROR_OK, ERROR_CONNECTION_UNAVAIL
    - Added constants for POWER GUIDs and system power conditions
    - Added constants for Static class : SS_ENDELLIPSIS, SS_WORDELLIPSIS
    - Added constants for shell notification events: SHCNE_*
    - Fixed GetModuleBaseNameA parameters
    - Changed SHILCreateFromPath -> added return value LONG
    - Commented constants DRIVE_CDROM and  LB_ITEMFROMPOINT, they are already part of TD libs to avoid collisions.
https://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

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

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

Post by Dave Rabelink » 17 Nov 2016, 10:02

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
https://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

RainerE
Germany
Posts: 2166
Joined: 27 Apr 2021, 12:40
Location: Germany

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

Post by RainerE » 17 Nov 2016, 12:12

Very good work!
Thx a lot

P.S.: nice to have seen you at the devcon!

Uwe van der Horst
Site Admin
Site Admin
Germany
Posts: 586
Joined: 05 Mar 2017, 14:21
Location: Wetter (Ruhr), Germany

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

Post by Uwe van der Horst » 20 Feb 2023, 17:43

I had some trouble with GetDeviceCaps. Sometimes the return value was correct, sometimes not (depending on the value of parameter 1). After changing DWORD -> HANDLE everything works now.
Screen Shot 02-20-23 at 06.39 PM.PNG
You do not have the required permissions to view the files attached to this post.
Best regards,
Uwe van der Horst
Advo-web GmbH

Uwe van der Horst
Site Admin
Site Admin
Germany
Posts: 586
Joined: 05 Mar 2017, 14:21
Location: Wetter (Ruhr), Germany

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

Post by Uwe van der Horst » 25 Feb 2023, 10:19

I have now migrated to x64. The WinApi32 Functions x64.apl helped a lot. The ShellExecuteW/ShellExecuteExW functions were missing. Following the instructions in Dave's WIKI article, I added two new parameters (4 bytes padding).

Struct_Info.PNG
You do not have the required permissions to view the files attached to this post.
Best regards,
Uwe van der Horst
Advo-web GmbH

Return to “Tools & Samples”

Who is online

Users browsing this forum: [Ccbot] and 0 guests