Accessing Pervasive.SQL With Perl

Page Last Modified: 17/03/14

Home Links ODBC (DBI) Contact

Win32::API - BTRCALL (2 of 3)

Win32::API requires the Perl application to specify the parameters and return data types for the function being called in the Windows DLL. There are 2 ways of doing this:

  1. specify a function prototype
     
  2. specify a parameter list

The prototype method is the newer, preferred option but unfortunately it appears to have an issue with (U)SHORT data types not being picked up correctly, with the result being that you get no return value and BTRCALL's SHORT parameters are not picked up correctly.

Therefore the following prototype, where C-types have been replaced with Win32::API data types, does not work:

SHORT BTRCALL(USHORT operation, LPVOID posBlock, LPVOID dataBuffer, LPWORD dataLength, LPVOID keyBuffer, BYTE keyLength, CHAR ckeynum)

but if we use the 32-bit INT (or DWORD) type instead (even though we only need 16-bits) the values are passed without a problem:

INT BTRCALL(INT operation, LPVOID posBlock, LPVOID dataBuffer, LPWORD dataLength, LPVOID keyBuffer, BYTE keyLength, CHAR ckeynum)

The parameter list method specifies each type via a string for parameters and a single-character string for the return type:

"IPPPPCc", "I"

Again we are using integer types for (U)SHORTs.

Win32::API returns an object for the function, with a method Call() that you use with the appropriate parameters. BTRCALL requires several buffers, for which we use strings - note that Win32::API expects with parameters that are pointers for you to pass the buffers by value/name and not by reference. Also, any buffers need to be allocated beforehand.

 

 

Home Links ODBC (DBI) Contact

All content on this site is copyright
Neil Hughes 2010 - 2020