Brethern --

Knowing that super search is my friend, I found this node that addresses this very issue.

So I go and download the appropriate DLL referenced in the article and looking at the documentation for Win32::API to import functions from DLLs and come up with the following code:

use Win32::API; my $idleTrackerInitHandle = Win32::API->new( "C:\\Perl\\dvl\\itunes\\IdleTrac.dll", "int IdleTrackerInit()" ); my $result = $idleTrackerInitHandle->Call(); #my $idleTrackerInitHandle = Win32::API->new( # "IdleTrac", "int IdleTrackerInit()" # ); #my $result = $idleTrackerInitHandle->Call(); #$function = Win32::API->new( # 'IdleTrac, 'int idleTrackerInitHandle-()', # ); # $return = $function->Call();
Where the DLL is in the same dir as the script, in windows/system, windows/system32, etc...

And the result I get is always: Can't call method "Call" on an undefined value at C:\Perl\dvl\itunes\GetIdleTime.pl line 6, <DATA> line 164.

I have never tried importing functions from a DLL before but when I tried the samples on the Win32::API doc pages, those worked fine. I tried the above code and a bunch more (passing parameters, etc) but cannot get it to work.

Does anyone know what I am doing wrong?

Many thanks,
mdog


In reply to Get idle time on a Windows box by mdog

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.