in reply to Win32::API question

You create dthe API object but you need to return a result from a call to that object. Note I do not have the dll in question so I can not test but I would think your code should look like this:

use Win32::API; my $filename="C:/Windows/ieuninst.exe"; my $Api = new Win32::API("fileversion.dll", "GetFileVersionTxt", P, P) +; # Set some memory aside for the returned value my $output = "\x00" x 1024; # Call the function in the dll $Api->Call($filename,$output); # Remove the unused padding in the string my $final = ($output =~ /(.*?)\x00/); print "\output - $final";

This is from an example in Chapter 9 of Win32 API from Win32 Perl Programming by David Roth modified to match your criteria. I would like to play with dll to test this as I think it would need some tweaking to run. I also suggest reading the pod for Win32::API as they have some excellent examples of getting data in and out of the functions loaded.

"No matter where you go, there you are." BB

Replies are listed 'Best First'.
Re: Re: Win32::API question
by Ven'Tatsu (Deacon) on Jun 02, 2004 at 18:16 UTC
    my $Api = new Win32::API("fileversion.dll", "GetFileVersionTxt", P, P) +;
    should be changed to
    my $Api = new Win32::API("fileversion.dll", "GetFileVersionTxt", ['P', + 'P'], 'I');
    or
    my $Api = new Win32::API("fileversion.dll", "GetFileVersionTxt", 'PP', + 'I');
    The third parameter is suposed to be a string or array ref of the input parameters, and the forth is a string for the return value.

      Cheers I alway forget the single quotes.

      I usually catch errors like that if I test code. But I was running from work without a dll to use. Oh well, maybe next time my first reply will be better ;)
      But than Win32::API for me is always sitting with a sample and changing it to meet my needs based on the functions called. Funny enough to see what got added to the meditations How to make Win32::API easy to use

      "No matter where you go, there you are." BB