Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Declaring Extern in QTP to call a DDE function inside a DLL **SOLVED**
#1
Solved: 11 Years, 3 Months, 2 Weeks ago
Declaring Extern in QTP to call a DDE function inside a DLL of a published third-party API

I am trying to automate a third-party windows software in QTP using provided API documentation but unfortunately the software and dll file are part of a legacy application (1999) and hence I suspect that the DLL functions are really using DDE (instead of COM). Fortunately, the API is fairly documented for the one function inside the dll file.
API documentation summary:
HLAPI calls have the following format:
HLAPI (function, data_string, length, return_code)
function is a 2 byte integer representing the HLAPI function to be performed.
The data_string is a pointer to a buffer to be used to exchange data.
The length is a 2 byte integer typically used to specify the size of the data_string buffer.
The return_code is a 2 byte integer typically used to pass a row/column or position coordinate on input and contains a return code on output.

For 32 bit Windows programming, all arguments are passed as pointers. The actual C prototype is defined as follows:
int APIENTRY HLAPI (WORD *function, BYTE *data_string, WORD *length, WORD *return_code)
To use the Windows 32 bit interface with Visual Basic, you need to specify a DECLARE FUNCTION statement using an ALIAS for the actual function name as follows:
Declare Function HLAPI Lib "hlw3.dll" Alias "_HLAPI@16" (fn%, ByVal s As String, ln%, rc%) As Integer


In QTP, I have it declared as
Extern.Declare micInteger, "hlapi", "C:\hlw3.dll", "_hlapi@16",micRef+micWord,micRef+micString,micRef+micWord,micRef+micWord
and calling it as
result = Extern.hlapi (3, string_buffer, 2, rc)
QTP executes this call and the result is always 0 and the string_buffer doesn’t return anything new. I even changed the declaration to just micString but still doesn’t work

It is indeed difficult to debug calls to DLLs even with the DLL let alone without it. Any help is appreciated.
Reply
#2
Solved: 11 Years, 3 Months, 2 Weeks ago
It worked after I changed micRef to micByRef

Extern.Declare micInteger, "hlapi", "C:\hlw3.dll", "_hlapi@16",micWord+micByRef,micString+micByRef,micWord+micByRef,micWord+micByReff
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SAPLIST is not recognised inside SAPTable mann 0 1,246 02-26-2018, 11:24 AM
Last Post: mann
  UFT - Check a checkbox inside a table cell sara- 0 5,706 02-02-2015, 08:07 PM
Last Post: sara-
Cool ntdll.dll crash problem with UFT 11.5 Application in Windows Server 08 gangadhar 1 4,805 06-13-2014, 04:43 PM
Last Post: vinod123
  Handling Object Repositories dynamically inside For Loop danny2012 3 4,049 07-13-2012, 02:00 PM
Last Post: danny2012
Exclamation Objects inside Pop up window not recognised. falvi 12 10,661 04-12-2012, 11:26 AM
Last Post: falvi

Forum Jump:


Users browsing this thread: 3 Guest(s)