text: how to use the WIN32API function in winrunner
  Thread: how to use the WIN32API function in winrunner
  01-26-2005, 07:47 AM #1
  vaseev01
  01-26-2005, 08:58 AM #2
  Re: how to use the WIN32API function in winrunner
  First, be aware that WinRunner provides no documentation for WIN32API. You will therefore want to become familiar with the following website:
  http://msdn.microsoft.com/library/de...y_category.asp
  A number of functions can be "preloaded" by calling the win32 api init script. It's a good idea to put the call in you're tslinit script so the default functions will be loaded whenever you start WinRunner:
  call_close "win32api" ();
  You will then see a number of functions in the function generator. These will only be a small subset of the API, however.
  If you want to call other functions there are basically two steps:
  1) Load the dll containing the function.
  2) Write an external function declaration for the function (see "External Function Declarations") in tsl online reference
  Many of the functions take or returns structures as paramaters. Since WinRunner doesn't support structures, the only way to call these functions is to write you're own dll which creates the structures and calls the function.
  win32 has it's own types which need to be mapped to one of the standard C Types for the external function declaration.
  char (signed and unsigned)
  short (signed and unsigned
  int (signed and unsigned)
  string (equivalent to C char*)
  long (signed and unsigned)
  To see how Win32 data types mapp to standard C types:
  http://msdn.microsoft.com/library/en...data_types.asp
  One more thing to keep in mind - the Win32 reference contains many constants that you don't know the value of. For example here is a snipet form a reference which shows how to set the password character for a password edit:
  <BLOCKQUOTE><PRE CLASS="clsCode"><TABLE border="0" cellpadding="0" cellspacing="0"><TR><TD>
  lResult=SendMessage(
  </TD><TD>//returnsLRESULTinlResult
  </TD></TR><TR><TD>(HWND) hWndControl,
  </TD><TD>// handle to destination control
  </TD></TR><TR><TD>(UINT) EM_SETPASSWORDCHAR,
  </TD><TD>// message ID
  </TD></TR><TR><TD>(WPARAM)wParam,
  </TD><TD>//=(WPARAM)()wParam;</TD></TR><TR><TD>(LPARAM)lParam
  </TD><TD>//=0;notused,mustbezero</TD></TR><TR><TD>
  </TD><TD></TD></TR></TABLE></PRE></BLOCKQUOTE>
  In order to use this, you would need to know the value of EM_SETPASSWORDCHAR (an unsigned int). The easisest way is to write a Win32 console program which spits out the value: