sgv_81 has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to write a script to process some information automatically using Perl and a Win 32 dll. The Perl code will make some calls to the dll functions (as C) against some files
I'm using Perl 5.10, and the ext Win32::API to make the calls into the library. My problem is that within the libray there's a struct defined as
Some functions I need depend on the former type definition, for example:typedef struct myTable { void* opaque; ///< Opaque pointer to storage } myTable;
The functions are exported correctly, but I don't know how to define myTable in Perl using Win32::API. I try to make the following calls, but they didn't work:__declspec(dllimport) myTable myTableCreate(); __declspec(dllimport) enum myStatus myTableLoadFromFile(char const* fi +lename, MyTable* pointToMyTable);
Win32::API::Struct->typedef( myTable => qw{PVOID opaque;}); my $CreateTable = new Win32::API("myDll.dll","myTable myTable Create() +"); my $LoadTableFromFile = new Win32::API("myDll.dll","int myTableLoadFro +mFile(char const* filename, LPMyTable pointToMyTable)")
I make then the following calls:
my $LeftTable = $CreateTable->Call(); my $pathTableLft = 'C:/Temp/Requests/CapBuy.TBL'; my $isLoaded = $LoadTableFromFile->Call($pathTableLeft,$LeftTable); print($isLoaded);
Unfortunately, it doesn't work: Win32::API::parse_prototype: WARNING unknown output parameter type 'myTable' at /us r/lib/perl5/site_perl/5.10/i686-cygwin/Win32/API.pm line 337. Can't call method "Pack" on an undefined value at ./API32.pl line 23.
Line 23 is my $isLoaded = $LoadTableFromFile->Call($pathTableLeft,$LeftTable);
Needless to point out that I'm both quite new using Perl and C. Any suggestion?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WIN32::API and void*
by bulk88 (Priest) on Jul 23, 2012 at 20:52 UTC | |
by sgv_81 (Novice) on Jul 24, 2012 at 08:41 UTC | |
by bulk88 (Priest) on Jul 24, 2012 at 18:25 UTC | |
by sgv_81 (Novice) on Jul 25, 2012 at 10:46 UTC | |
by bulk88 (Priest) on Jul 25, 2012 at 15:13 UTC | |
|