Micro Focus QTP (UFT) Forums
Declaring Extern in QTP to call a DDE function inside a DLL **SOLVED** - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Declaring Extern in QTP to call a DDE function inside a DLL **SOLVED** (/Thread-Declaring-Extern-in-QTP-to-call-a-DDE-function-inside-a-DLL-SOLVED)



Declaring Extern in QTP to call a DDE function inside a DLL **SOLVED** - ramuk - 06-07-2012

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.



RE: Declaring Extern in QTP to call a DDE function inside a DLL of a published third-part - ramuk - 06-07-2012

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