I'm trying to write a Perl script to access a device through National Instrument's gpib driver (specifically through their dll).

Looking at the documentation for the Win32::API module, I can see how to access functions in a dll file. However, I also will need access to some global pointer variables from the dll. I haven't figured out if the Win32::API module can give me access to those variables.

Does anyone have any suggestions or ideas on how to access variables in a dll file?

--------------------

Before the questions begin, I probably should share a few other details about my reasons for not pursuing other methods.

  1. gpib::ni --> This uses XS and I'm encountering a compiler issue that is preventing the module from installing. My search of the web leads me to believe that the issue is related to using a different compiler (and/or compiler version) that what ActiveState used to compile their Perl distribution.

    (Contacting the module developer for help is no longer an option. Based on information on his web site, he passed away last year.)

  2. XS, SWIG, Inline --> These methods/module requires the use of a compiler, which probably means that I'll have a similar issue as described above.

    Plus, my end goal is to use ActiveState's PerlApp to create a stand-alone executable that can be run from any Windows box. The systems that would actually use the code don't have access to the internet and I don't want the headache of managing the Perl environment of possibly hundreds of systems.

    Anyways, I'd like to avoid having to distribute a compiler on each machine in order for them to use the stand-alone executable.
Any ideas, suggestions, or pointers would be greatly appreciated.

From NI's documentation on their free driver, the following variables are "exported":

int *user_ibsta; int *user_iberr; int *user_ibcnt; long *user_ibcntl;
After calling some of the functions, I would need to check the value of these variables to determine if an error occurred.

From NI's documentation, here's examples of how to access the variables from C/C++:

HINSTANCE Gpib32Lib = NULL; Gpib32Lib=LoadLibrary("GPIB-32.DLL"); if (Gpib32Lib == NULL) { return FALSE; } Pibsta = (int *) GetProcAddress(Gpib32Lib,(LPCStr)"user_ibsta"); Piberr = (int *) GetProcAddress(Gpib32Lib,(LPCStr)"user_iberr"); Pibcntl = (long *) GetProcAddress(Gpib32Lib,(LPCStr)"user_ibcnt");

In reply to How to use Win32::API to access variable in DLL file? by dasgar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.