Nemurenai,
There's a fairly simple demonstration of your point that can be taken from the Win32::API docs - one that doesn't need a laptop to test out.
Save the following file as 'mymod.pm':
package mymod; use warnings; use Win32::API; #### define the structure Win32::API::Struct->typedef( POINT => qw{ LONG x; LONG y; }); #### import an API that uses this structure Win32::API->Import('user32', 'BOOL GetCursorPos(LPPOINT lpPoint)'); #### create a 'POINT' object my $pt = Win32::API::Struct->new('POINT'); #### call the function passing our structure object GetCursorPos($pt); #### and now, access its members print "The cursor is at: $pt->{x}, $pt->{y}\n"; 1;
When you run that file as 'perl mymod.pm' you get output like the following (depending upon just where the cursor is located):
D:\pscrpt>perl mymod.pm The cursor is at: 584, 1017 D:\pscrpt>perl mymod.pm The cursor is at: 213, 542
Next, try running the following script (named 'test.pl'):
use warnings; use mymod;
That consistently produces the following output for me (with an accompanying segfault):
D:\pscrpt>perl test.pl Win32::API::parse_prototype: WARNING unknown output parameter type 'BO +OL' at D:/ perl58_M/site/5.8.8/lib/Win32/API.pm line 273. Use of uninitialized value in concatenation (.) or string at mymod.pm +line 21. Use of uninitialized value in concatenation (.) or string at mymod.pm +line 21. The cursor is at: ,
I can't offer a useful explanation of this ... but I guess it has something to do with the quirky way that Win32::API::Struct goes about doing whatever it is that Win32::API::Struct does.

I don't think that Win32::API::Struct enables you to do anything that can't be done by using simply Win32::API.
Win32::API::Struct merely simplifies the coding that's necessary. So you should be able to rewrite your code (using only Win32::API) in such a way that avoids the odd behaviour you've noted.

Cheers,
Rob

In reply to Re: Win32::API missing types by syphilis
in thread Win32::API missing types by Nemurenai

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.