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:
This gets rid of the Line 23 Error (Can't call mehtod "Pack on an undeifned value at ./API32.pl line 23).my $LoadTableFromFile = new Win32::API("myDll.dll","int myTableLoadFro +mFile(char* filename, LPHANDLE pointToMyTable)")
"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:
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 istypedef struct myTable{ void* opaque; ///< Opaque pointer to storage } myTable;
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.Win32::API::Struct->typedef( myTable=> qw{PVOID opaque;});
"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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |