Accessing Pervasive.SQL With Perl

Page Last Modified: 20/07/12

Home Links ODBC (DBI) Contact

Win32::API Examples 1 - getting client/engine versions

A simple example where we call BTRCALL once to get version information:

use strict;
use warnings;
use 5.010;
use Win32::API;

# old parameter format
my $funchandle = new Win32::API("w3btrv7.dll", "BTRCALL", "IPPPPCc", "I");

if (defined $funchandle)
{
say "funchandle set";
my $operation = 26; # get version information
my $posBlock = " " x 128;
my $dataBuffer = " " x 255; # maximum buffer size is 255 bytes
my $dataLength = 15; # ...we need to specify >= 15 bytes to get full version info
my $keyBuffer = " " x 255; # actually no need to set key buffer info for this example...
my $keyLength = 255; # ...because none of it is used
my $keyNumber = 0;

say "Calling function...";
my $return = $funchandle->Call($operation, $posBlock, $dataBuffer, $dataLength, $keyBuffer, $keyLength, $keyNumber);

say "return = $return";
say "data buffer = $dataBuffer";

my($version1, $revision1, $type1, $version2, $revision2, $type2, $version3, $revision3, $type3) = unpack('SSCSSCSSC', $dataBuffer);

say "Client: version = $version1, revision = $revision1, type = $type1 (".chr($type1).")";
say "Workgroup engine: version = $version2, revision = $revision2, type = $type2 (".chr($type2).")";
say "Server engine: version = $version3, revision = $revision3, type = $type3 (".chr($type3).")";
}
else
{
say "funchandle not set";
}

The type fields are characters that get set to 'S' for server engine, 'N' for requester/client, 'D' for DOS Btrieve engine, 'P' for OS/2 engine and 'W' for Windows workgroup/workstation engine.

Home Links ODBC (DBI) Contact

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