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

typedef struct myTable { void* opaque; ///< Opaque pointer to storage } myTable;
Some functions I need depend on the former type definition, for example:
__declspec(dllimport) myTable myTableCreate(); __declspec(dllimport) enum myStatus myTableLoadFromFile(char const* fi +lename, MyTable* pointToMyTable);
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:
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?


In reply to WIN32::API and void* by sgv_81

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.