Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Win32::API giving a program error

by Anonymous Monk
on Jun 03, 2004 at 16:19 UTC ( [id://360244]=note: print w/replies, xml ) Need Help??


in reply to Re: Win32::API giving a program error
in thread Win32::API giving a program error

Hi again,
again, thanks to you both for your suggestions, I tried a good few variations on the buffer size, but without success. The same error message appeared... I also tried using windows style file paths, and included the change of my ($final) = $string =~/(.*?)\x00/;. But this also had no effect. The code now appears like this:
#!usr/bin/perl use Win32::API; my $filename="C:\\Program Files\\America Online 9.0g\\aol.exe"; my $apiobject = new Win32::API("C:\\Documents and Settings\\Mdaviesie\ +\Desktop\\dver_1.3\\fileversion.dll", "GetFileVersionTxt", 'PP','I') +or die "Failed to acquire API: $^E"; #Set some memory aside for the returned value my $string="\x00" x 1024; #Call the function in the dll $apiobject->Call($filename,$string)| die "died at line 16"; #Remove the unused padding in the string my ($final) = $string =~/(.*?)\x00/; print "\$final - $final";
I'm still no closer to figuring this one out, so if anybody out there could help me it would be greatly appreciated.
Thanks in advance,
Jonathan

Replies are listed 'Best First'.
Re^3: Win32::API giving a program error
by Anonymous Monk on Jun 03, 2004 at 17:08 UTC
    I know this a not really an awnser to your question, but depending on what you are doing it may offer a solution.
    Are you totally commited to using the Win32::API?
    You can get the information you require using OLE as well, and it is much simpler.
    use Win32::OLE; $file = "M:\\poledit.exe"; $fso = Win32::OLE->new('Scripting.FileSystemObject') or die "Cannot op +en File System Object"; $companyname = $fso->GetFileName ($file); $version = $fso->GetFileVersion ($file); print $companyname, "\t", $version;
    Of course if you are looking to do more with the Win32:API then this doesn't really help you. :-)
Re^3: Win32::API giving a program error
by Anonymous Monk on Jun 03, 2004 at 17:01 UTC

    At this point I would start trying different versions of the software involved to see if it is some obscure bug that was recently introduced or fixed. For example, I might:

    1. Make sure I have the latest Win32::API. If not, use PPM to install the latest version. You can also check search.cpan.org to see if there is an bug report, or a note in the change log describing your problem. There may also be something in the Win32::API documentation (Note: I am not implying the Win32::API is the cause of the problem, but it can hurt to look).
    2. Are there other versions of your DLL you can try?
    3. Try a different version of ActivateState perl. I have had good success installing different versions of ActivateState Perl side by side on Win2K Systems. Just keep an eye on your PATH.

    It may seem extream to try different versions of your software, especially Perl. But, it seems like there is little information pointing to the exact cause of the error. By trying some of these points above, you might find a combination that works. I know, I don't like poking at a problem with a stick, but there isn't much to go on here. :-)

    Your error message said that a log file was generated. Any info in there?

    Ted

    Disclamer: I am quite braindead at times and so cannot be held responsible for damage caused by following my advice. That, I am a lowsy speler.

Re^3: Win32::API giving a program error
by jdavidboyd (Friar) on Jun 03, 2004 at 17:33 UTC
    You have your output parameter set as an Integer. That can't be good...

    Should probably be N or P, no?
      The previously stated function signature take 2 pointers to strings and retunrs and integer, so that should be correct.
      INT GetFileVersionTxt(STRING sFile, out STRING sVersion)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-19 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found