Can I call a Win32 API method from TestStand?

Updated Mar 28, 2024

Reported In

Software

  • TestStand

Programming Language

  • C++

Other

Win32

Issue Details

I would like to call a Win32 API method(ex: GetPrivateProfileStringA) from TestStand.
How could I achieve it?

Example for Win32 API function:

Winbase.h header - Win32 apps | Microsoft Learn

Solution

You can achieve it by below steps.
It is recommended to use the A variants for Win32 API calls rather than the W variants, because W variants are Wide / Unicode and A variants are plain ANSI.

  • In TestStand, create a C++/DLL Action Step.
  • Select the DLL that contains the Win32 API call. (This might require searching online.)
  • Select the method which you want to use and choose the A variant.
  • When you get this popup, ignore it. (TestStand is complaining that it doesn't know the prototype and cannot autocreate the required parameters.)螢幕擷取畫面 2024-03-25 150726.png
  • Add parameters and configure them to match TestStand data types to Win32 API data types.
Here is a list of data types in the Win32 API.
(Windows Data Types (BaseTsd.h) - Win32 apps | Microsoft Learn)

Here is a summary of common data types and how they map to TestStand
螢幕擷取畫面 2024-03-25 150858.png

Here is an example:
螢幕擷取畫面 2024-03-25 150944.png