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

Hi Monks, I would like to write a small pm file using win32::api.Is it possible to place any dll under site/lib/auto? I´m using a dll from microsoft sdk and now i was wondering if its possible to place the dll under auto but i have no idea how the script can find it there. I guess it´s not possible. ... any ideas ? Thanks

Replies are listed 'Best First'.
Re: Write module with own dll.
by Corion (Patriarch) on Aug 05, 2008 at 07:31 UTC

    If you want to use a DLL that does not come with Windows, the best approach is to copy it into the same directory where perl.exe lives. That way, Win32::API, Windows and perl.exe will be able to find it.

      The problem is i need to roll out this "module" on X machines. Is it possible to handle this with ppd?
      I wont be able to log on to every machine and place a copy of the dll in the perl directory.
      Thanks for your help and fast reply ...

        Personally, I would leave distribution of files to whatever mechanism is in place for administrating the machines you have, but I understand that this is not always possible.

        I don't use PPD, so I don't know how it specifies files that should go into the bin directory of the Perl distribution.

        From reading some documentation on LoadLibrary, Windows also looks in the current directory to load a DLL, so you could change to the directory and then try to load the DLL through Win32::API. I haven't tried that myself.

        If all else fails, you have to look how DynaLoader does its magic on Win32.

        Is it possible to handle this with ppd?

        Yes - for an example of how this is usually done see the ppd file for Crypt::SSLeay at http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd. Note the <INSTALL EXEC .... </INSTALL> command and the install script that it calls (which installs the 2 SSL dll's) at http://theoryx5.uwinnipeg.ca/ppms/scripts/install_ssl.

        Another alternative to that is to place the dll in the blib/script directory of the ppm binary - in which case the dll will automatically be placed in perl/site/bin (unless there are permissions issues which forbid it).
        Update: Actually, it might go into perl/bin, not perl/site/bin ... not sure offhand.

        Cheers,
        Rob