Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How to pass a pointer to an array of 'unsigned char' C data type with Win32::API ("U0")

by apeks_okad (Novice)
on Jul 28, 2016 at 11:08 UTC ( #1168719=note: print w/replies, xml ) Need Help??


in reply to Re: How to pass a pointer to an array of 'unsigned char' C data type with Win32::API ("U0")
in thread How to pass a pointer to an array of 'unsigned char' C data type with Win32::API

Oh... now that makes sense.

So I changed the code accordingly as follows

my $data_ref = pack ('U0C*', (0x81 , 0x55, 0x00, 0xE0));

But still end up with the same problem

Maybe its worth the mention that I use Strawberry Perl 5.24.0 (32Bit) on a Win7 64 Bit Machine (since the DLL provided by the manufacturer is a 32 Bit DLL). Could this lead to problems with the array reference?

  • Comment on Re^2: How to pass a pointer to an array of 'unsigned char' C data type with Win32::API ("U0")
  • Download Code

Replies are listed 'Best First'.
Re^3: How to pass a pointer to an array of 'unsigned char' C data type with Win32::API ("U0")
by syphilis (Archbishop) on Jul 28, 2016 at 14:04 UTC
    Could this lead to problems with the array reference?

    I don't see any reason that should lead to any problems.

    There are other approaches (apart from Win32::API) that you can take - eg XS or Inline::C.
    I personally prefer either of those (especially the latter) over Win32::API as I've always found Win32::API difficult to get right - though it's possible that the deficiency is in me, as opposed to Win32::API.

    For XS/Inline::C you'll need the header file (which it seems you already have), the dll (which you definitely already have) and a suitable import library (which you might not have).
    To create the import library ( let's call it libAID.a), place a copy of AID.dll in the cwd and run:
    gendef AID.dll dlltool --kill-at --input-def AID.def --output-lib libAID.a
    I would then install Inline::C and access the dll functionality using it.
    (You'll want to first run perldoc Inline::C-Cookbook for some basic instructions on how to successfully use the module.)

    Cheere,
    Rob
Re^3: How to pass a pointer to an array of 'unsigned char' C data type with Win32::API (error)
by tye (Sage) on Jul 28, 2016 at 14:07 UTC

    I don't see any reason for Perl to crash. But you don't even provide the error message associated with the Perl crash so we don't have much to go on to diagnose the problem.

    - tye        

      The error message is a windows error "Perl interpreter does not function anymore" (translated from the original German Error "Perl interpreter funktioniert nicht mehr"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1168719]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-12-08 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?