mdog has asked for the wisdom of the Perl Monks concerning the following question:
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:
Where the DLL is in the same dir as the script, in windows/system, windows/system32, etc...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();
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get idle time on a Windows box (die)
by tye (Sage) on Jul 29, 2005 at 21:45 UTC | |
|
Re: Get idle time on a Windows box
by Ace128 (Hermit) on Aug 03, 2005 at 07:36 UTC | |
by mdog (Pilgrim) on Aug 07, 2005 at 23:52 UTC | |
by Ace128 (Hermit) on Aug 19, 2005 at 18:15 UTC |