Re: Problem with Win32::API and pointers



jrgoody@xxxxxxxxxxxxxx wrote:
Hi,

I'm working on a project and trying to use the Win32::API to call a
DLL from Perl, but I have some problems. I'm using the last version
of the API (0.41).

I'll describe my problem. I hope someone can help me. The DLL I've
been trying to call from Perl is the FTD2XX.dll from FTDI, a Library to
communicate with a chip connected to the computer via USB. The thing is
really simple, this is my code:

#CODE
STARTS******************************************************************************
use Win32::API;

Win32::API::Type->typedef( 'FT_HANDLE', 'PVOID' );
Win32::API::Type->typedef( 'FT_STATUS', 'ULONG' );

#FT_Open
Win32::API->Import( 'FTD2XX', 'FT_STATUS FT_Open(int
deviceNumber,FT_HANDLE *pHandle)' );

#FT_Close
Win32::API->Import( 'FTD2XX', 'FT_STATUS FT_Close(FT_HANDLE ftHandle)'
);


#Open port
FT_Open(0,$ft_handle);

#Close port
$ft_status = FT_Close($$ft_handle);

This looks wrong. You are treating $ft_handle like a reference to a perl scalar. But it contains the address of a void pointer.

I think you have to dereference the pointer in $ft_handle, but I have no idea how to accomplish this with Win32::API. I googled for it, but nothing helpful came up.

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
.



Relevant Pages

  • Re: Problem with Win32::API and pointers
    ... DLL from Perl, ... I do not know that you need to switch to this syntax to use the "preallocate before, ...
    (comp.lang.perl.modules)
  • Re: The procedure entry point Perl_Glockhook_ptr could not be located in the dynamic link library pe
    ... There's no way to resolve this issue short of upgrading the perl version itself? ... The procedure entry point Perl_Glockhook_ptr could not be located in the dynamic link library perl58.dll ... I spent a whole day trying to what caused and found out ActiveState dll had a wrong version DLL in the 5.8.7 distro ... This e-mail communication and any attachments may contain confidential and privileged information for the use of the ...
    (perl.dbi.users)
  • Re: Win32::API cannot load any DLL?
    ... I've decided to try SWIG as my solution. ... as Ruby to load my dll without any problem. ... I hope you tried to run the script as 'perl msdll.pl' not 'perl msdll.dll' ...
    (comp.lang.perl.misc)
  • DLL Call Follies
    ... my head against the wall trying to get Win32::API interfacing to a dll ... the work space must be at least 32k bytes (bigger won't ... Error codes are listed in the "Return Error Codes" section of this ... Perl is throwing an error dialog "Perl Command Line ...
    (comp.lang.perl.misc)
  • Re: Parsing Google-like queries for FT search
    ... but i didn't find any mention of perl in your question. ... SQL2005 you can declare external stored function using win DLL (this was ... true also on SQL2000) and any CLR language. ... I'm planning of testing this way in the next couple of days, ...
    (microsoft.public.sqlserver.fulltext)