Click here to get back home

win32api::file translation of c-code to perl: help pls

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
win32api::file translation of c-code to perl: help pls Susanne West 04-21-2008
Get Chitika Premium
Posted by Susanne West on April 21, 2008, 9:20 am
Please log in for more thread options

i have the following c-code that sould send out a
command through deviceIO using win32api::file, and
i'm struggling with the proper handling of the code.
the result of my DeviceIoControl() command is always
NULL...

#! perl
# -------------------------------
# c-code:
# define BUFF_SIZE 0x2c
# HANDLE hHandle = CreateFileA("\.\APPDRV",
#                GENERIC_READ|GENERIC_WRITE, 0,
#                NULL, OPEN_EXISTING, 0x80, NULL);
#
# char buffer[BUFF_SIZE];
# memset(buffer, 0, BUFF_SIZE);
# buffer[0] = 0x04;
# buffer[1] = 0x00;
# buffer[2] = 0x06;
# buffer[3] = 0x00;
# buffer[4] = 7;
# buffer[5] = 7;
#
# DWORD bytesReturned;
# BOOL result = DeviceIoControl(hHandle, 0x23209C,
# buffer, BUFF_SIZE, buffer, BUFF_SIZE, &bytesReturned, NULL);
#-------------------------------
#
#for testing, this should translate into the following:

$hDevice = createFile("\.\APPDRV", "rw", '' );
if (! $hDevice){ die("Could not open device! \n"); }
print "Device open\n";                #this seems to be working

$buffer = chr(04) . chr(0) . chr(06) . chr(0) .
7 . 7 . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0) .
chr(0) . chr(0) . chr(0) . chr(0);

$res = DeviceIoControl( $hDevice, 0x23209C, $buffer, 44, $opOutBuf, 44,
$olRetBytes, $pOverlapped );
if (! $res){ print "IO control failed\n"; } # this fails


am i missing something here?

thanks for any hints...





Posted by smallpond on April 21, 2008, 12:56 pm
Please log in for more thread options
> i have the following c-code that sould send out a
> command through deviceIO using win32api::file, and
> i'm struggling with the proper handling of the code.
> the result of my DeviceIoControl() command is always
> NULL...
>
> #! perl

#!/usr/bin/perl
use warnings;
use strict;

> am i missing something here?
>

Yes. You are missing the error messages for your
undefined functions.
--S

Similar ThreadsPosted
How to reuse the FS_ wordlist from Win32API::File? March 31, 2006, 6:15 pm
Perl translation needed for simple bat file March 10, 2006, 12:25 am
perl re "translation" August 6, 2005, 3:01 am
WIn32API and keyboard September 26, 2006, 9:42 am
Win32API::Registry, RegOpenKeyEx fails [The parameter is incorrect] November 28, 2004, 2:10 pm
best perl l10n solution that can support online translation and change management April 3, 2006, 9:02 am
Translation please January 17, 2007, 4:30 pm
Looking for Chinese->English Translation Script September 13, 2005, 8:29 pm
Perl/unix script to convert a fixed width file to a tab delimited file September 29, 2007, 9:35 am
Read xml file and write data to a txt file using PERL.... urgent April 17, 2007, 4:17 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap