RE: How to passing a hex number in Win32::API call
by Yu Su other posts by this author
Oct 26 2009 5:29PM messages near this date
view in the new Beta List Site
ActiveState announces ActivePerl 5.10.1 build 1006
|
RE: how to use a pointer returned by a Win32::API call
Hi,
I have a DLL from FTDI (ftd2xx.dll www.ftdichip.com) for a USB device. I
try to write a simple perl script to list a number of (FTD) USB devices
connected to a PC. My code below got an error on invalid parameter;
Argument "M-\0\0\0\0\" isn't numeric in subroutine entry at demo.pl line
#
I guess I did not pass a hex data in the function call properly. Can
someone help me?
Thanks.
Eugene
######## code snippet #######
use strict;
use Win32::API;
use Carp;
use warnings;
# from FTD2xx programmer guide:
# FT_ListDevices(PVOID numDevs,PVOID NULL,DWORD FT_LIST_NUMBER_ONLY)
# FT_LIST_NUMBER_ONLY is defined in FTD2xx.h as
#define FT_LIST_NUMBER_ONLY = 0x80000000
#
my $function = new Win32::API("ftd2xx", "FT_ListDevices", "PPN", "N");
if (not defined $function) {
die "Can't import API FT_ListDevices: $!\n";
}
my $DevBuffer = " " x 80;
my $FT_LIST_NUMBER_ONLY=pack('N', 0x80000000);
my $status=$function-> Call($DevBuffer,0,$FT_LIST_NUMBER_ONLY);
print "status: $status\n";
print "DeviceNumber: $DevBuffer";
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Jan Dubois
Yu Su
Yu Su
Brian Raven
Sisyphus
Jan Dubois
|