DaleCooper has asked for the wisdom of the Perl Monks concerning the following question:

I hope somebody can help me with this.

I am trying to use OLE to load a 'Scripting.FileSystemObject' object to get at a file's version. All is well when I run this as a pure script, but when bundled inside a pp built exe, I get an error.

I have seen that some other people have asked questions along these lines, but I was unable to find any resolutions out there?

CODE:

use Win32::OLE ; sub getVersion($){ return undef unless defined $_[0] ; my $vbsObject = Win32::OLE->new('Scripting.FileSystemObject') ; my $vbsFile = $vbsObject->getFile("$_[0]") ; return $vbsObject->GetFileVersion($vbsFile->{'Path'}) eq '' ? unde +f : $vbsObject->GetFileVersion($vbsFile->{'Path'}) ; }
ERROR:

Can't load 'C:\DOCUME~1\dcooper\LOCALS~1\Temp\par_priv.2564.tmp\nDCEaSeL9M.dll' for module Win32::OLE: load_file:The specified procedure cou ld not be found at D:/cpanrun/build/5-8-0/lib/DynaLoader.pm line 229.

Replies are listed 'Best First'.
Re: pp generated exe can't find DLL when using OLE
by radiantmatrix (Parson) on Feb 01, 2005 at 14:16 UTC

    It seems to me like you might need to explicitly include DynaLoader.pm in your archive. Check the pp manual for instructions on how to do that. If you envision yourself compiling Perl for Windows regularly, you might want to check out ActiveState's PDK; it contains a tool called 'PerlApp' that makes PAR-like packing incredibly convenient.

    Back when I started using Perl, that's all I used. It actually helped me learn to use PAR, since it shows you the commmand line it's passing for the build.

    radiantmatrix
    require General::Disclaimer;
    s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}

      No. That error message is generated by DynaLoader (specifically dl_load_file). It's saying that it can't load nDCEaSeL9M.dll for Win32::OLE due to a system error (ERROR_PROC_NOT_FOUND).

      DaleCooper needs to turn on the env var PERL_DL_DEBUG to see if he can get some debugging messages, and/or examine his system logs (in EventViewer).

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

        Thanks, guys.

        The set PERL_DL_DEBUG=true got me started. Strange thing was that the OLE.DLL is where things were going P*P.

        When I ran the pp command in verbose mode and with the PERL_DL_DEBUG, OLE.dll is never mentioned, even though I have explicitly refered to it in the pp command line?

        pp -v -B -l "C:\Perl\site\lib\auto\Win32\OLE\OLE.dll" -M Win32:OLE -o +PatchMeThese.exe PatchMeThese.pl
        I then ran PPM to query which version of OLE I had. PPM couldn't find Win32-OLE or OLE, so I simply installed, run the PP command the output was a working exe.

        Strange but fixed.

        Many Thanks,

        Dale
Re: pp generated exe can't find DLL when using OLE
by PodMaster (Abbot) on Feb 01, 2005 at 15:34 UTC
    Which version of PAR/OLE do you have? I can't get your example to work, but I've no problem pp-ing up the following with the latest PAR/Win32::OLE (PAR 0.86, Win32::OLE 0.17).
    use strict; use Win32::OLE qw[in with]; my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); my $size = 0; my $d = $fs->GetFolder("$ARGV[0]"); eval { $size = $d->size( ); my $size_gb = ($size/1024/1024); print "Size: ".$size_gb."Mb ($size byte)"; };
    Works without a hitch. My perl is ActivePerl 5.8.4.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.