----- Original Message ----- 
From: "Rogers, John" <[EMAIL PROTECTED]>
To: "'Perl-Win32-Users (E-mail)"
<[email protected]>
Sent: Wednesday, April 20, 2005 5:00 PM
Subject: Win32-API and ghostscript API




>  -----Original Message-----
> From: Rogers, John
> Sent: Wednesday, 20 April 2005 4:56 PM
> To: Perl-Win32-Gui-Users (E-mail)
> Subject: Win32-API and ghostscript API
>
> hi,
> I want to access the ghostscript API for the gsdll32.dll.
>
> been trying this any which way cant make it work, I must be doing some
> thing wrong any Ideas ?
> ###########
> use strict;
> use Win32::API;
>
>     Win32::API::Struct->typedef( REVINFO => qw{
>     CHAR *product;
>     CHAR *copyright;
>     LONG revision;
>     LONG revisiondate;
> });
> my $rev = Win32::API::Struct->new('REVINFO');
> Win32::API->new('C:\gs\gs8.15\bin\gsdll32.dll','gsapi_revision','CCNN',V)
> or die "no-worky $! $^E";
>
> print $rev->{revision};
> ###################

Here's one way that works ok for me with version 7.00 of ghostscript -
though I'm not entirely sure that the string buffers have been set to the
correct length.
---------------------------------
use warnings;
use Win32::API;

my $p = '' x 17;
my $c = '' x 70;

my $product = pack('P', $p);
my $copyright = pack('P', $c);
my $revision = pack('L', 0);
my $revisiondate = pack('L', 0);

my $info =
 new Win32::API('D:\ghostscript\gsdll32.dll',
                'gsdll_revision',
                'PPPP', 'V');

if(!defined($info)) {print "ERROR: $!"}

$info->Call($product, $copyright, $revision, $revisiondate);

print "\nProd: ", unpack('P17', $product),
      "\nCopy: ", unpack('P70', $copyright),
      "\nRev: ", unpack('L', $revision),
      "\nDate: ", unpack('L', $revisiondate), "\n";
__END__
-------------------------------------

I've just now noticed that the function you're accessing is called
'gsapi_revision' whereas I'm accessing 'gsdll_revision'. It looks like the
same function. Has it simply been renamed in your more recent version of
ghostscript, or have I gone and accessed the wrong function ? I couldn't
find anything on 'gsapi_revision' in my ghostscript docs (though I didn't
spend a lot of time looking).

You'll note that I haven't used Win32::API::Struct - mainly because I'm not
very familiar with it. I think the task should be achievable with
Win32::API::Struct - if you would prefer a solution along those lines then
let us know and I'm sure someone will oblige.

(The packing and unpacking was necessary because gsdll_revision() takes C
pointers as its arguments.)

Cheers,
Rob

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to