Bulk88, thanks for your reply. You made truly helpful points.

Here you are some Q's and A's. Spoiler alert, some of them might be quite obvious (sorry, newbie):

"If you want a C void * in Win32 API use UINT_PTR instead." Hence,

Win32::API::Struct->typedef( cTbl => qw{UINT_PTR opaque;});
?

"Are you sure that that is myTable and not myTable *?".

Yes, it returns the object myTable and not myTable*. At least according to the h files. (I would have expected a pointer too)

"think 'myTable myTable' is a typo "".

You are absolutely right, it should read as the declaration above. Luckily the typo wasn't in my code. How can I introduce changes after Ctrl-C Ctrl-V something? I call it a finger dislexia.

"In any case, you can't return a Win32::API::Struct as the return value since its not implemented"".

Does this mean that I can't use Win32::API to link to this function? Is ther any workaround? Because without this functionality, I think I may not be able to call any other function. At the end of the day, tables need to be created to pass them as parameters.

"Try replacing LpMyTable with LPHANDLE, or upgrading to my version of Win32::API".

I'm using Win32::API 0.68, is there a newer version in CPAN I have totally ignored? Anyways, if I go for LPHANDLE, I understand that this should work:

my $LoadTableFromFile = new Win32::API("myDll.dll","int myTableLoadFro +mFile(char* filename, LPHANDLE pointToMyTable)")
This gets rid of the Line 23 Error (Can't call mehtod "Pack on an undeifned value at ./API32.pl line 23).

"My final question is, why are you using the myTable struct instead of a UINT_PTR */LPHANDLE?"

No smart answers to that one, in the defininition of myTable in the API header:

typedef struct myTable{ void* opaque; ///< Opaque pointer to storage } myTable;
So, through the documentation in http://search.cpan.org/~cosimo/Win32-API-0.68/API.pm#USING_STRUCTURES I've decided that the way to define this structure in perl is
Win32::API::Struct->typedef( myTable=> qw{PVOID opaque;});
Probably, PVOID has to be changed by UINT_PTR (?) or are you suggesting that all the myTable calls should be changed into LPHANDLE or UINT_PTR * (I don't think I have understood the difference between them). Actually not defining the structure in perl would be nicer.

"is myTable something you invented to emulate void ** or myTable is from your C API's headers? does myTable have other secret members after member opaque? Does "myTable myTableCreate();" really return a "myTable" and not a "myTable *"? "

Well, I wish this were me trying to opaque my API as much as possible. What happens it's that I'm just the client of this library wich handles some talbes I normally handle them using its GUI interface but I need to compare every day that there are no changes between to different sets of tables (more than 40 in each set). This is why, I'm trying to write a script that checks the differences making calls to this library and write a report with any changes. I have a compiled dll and the h files with the exports of the library, so it's not really I have the flexibility to modify that part of the C code. I'm quite restricted to the function definitions provided in the dll, I'm afraid. I can't see any other members after/before the opaque member, but again I can't see the implementation of myTable, only the h files and according to those files, myTableCreate() returns myTable not myTable*.


In reply to Re^2: WIN32::API and void* by sgv_81
in thread 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.