"Rogers, John" wrote on 04/20/2005 02:00:58 AM:
>
> -----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 ?
I made corrections to your program, but did not get it to work first try,
and I don't have time to spend on it right now. I've made comments below.
> ###########
> 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');
I haven't used Win32::API::Struct. I'll have to get more familiar
before I can get a working version.
> Win32::API->new('C:\gs\gs8.15\bin\gsdll32.
> dll','gsapi_revision','CCNN',V) or die "no-worky $! $^E";
This call returns an object which you must save. The DLL function is not
invoked. According to GS 8.50 documentation, the gsapi_revision interface
is if gsapi_revision(&r, sizeof(r)), where r is a REVINFO struct. So your
description of the interface ('CCNN','V') is incorrect. Also, 'C' is a
char, not a *char. Passing a pointer to a structure that contains pointers
makes it a little tricky defining the interface. You'll have to pack Perl
variables into a 'binary' string. I don't have it correct yet - that's why
I haven't gotten it to work.
> print $rev->{revision};
The function has not been invoked. You need $obj->Call(parms) where
$obj is the return from the Win32::API->new.
Here's what I've got so far. Passing of parameters still needs to be
resolved.
#==================================================================
use strict;
use Win32::API;
use vars qw($GS_Rev);
Win32::API::Struct->typedef( REVINFO => qw {
CHAR *product;
CHAR *copyright;
LONG revision;
LONG revisiondate;
} );
my $rev = Win32::API::Struct->new('REVINFO');
my $DLL = 'C:\Program Files\gs\gs8.50\bin\gsdll32.dll';
$GS_Rev = Win32::API->new($DLL,'gsapi_revision','PL','V')
or die "no-worky $! $^E";
### need to fix interface spec
#
$rev = $GS_Rev->Call(???);
print $rev->{revision};
#==================================================================
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs