Re: Problem with Win32::API and pointers
- From: Thomas Kratz <ThomasKratz@xxxxxxxxxxxxxxxx>
- Date: Fri, 12 May 2006 17:25:04 +0200
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^.-
.
- Follow-Ups:
- Re: Problem with Win32::API and pointers
- From: harryfmudd [AT] comcast [DOT] net
- Re: Problem with Win32::API and pointers
- References:
- Problem with Win32::API and pointers
- From: jrgoody
- Problem with Win32::API and pointers
- Prev by Date: Problem with Win32::API and pointers
- Next by Date: Re: HTML to XML in Perl?
- Previous by thread: Problem with Win32::API and pointers
- Next by thread: Re: Problem with Win32::API and pointers
- Index(es):
Relevant Pages
|