1

I am trying to import a C++ DLL in Perl (Active Perl 5.12.2 Build 1202). My Subroutine for this is:

sub _import
    {
        my ($func,$params)=@_;
        print "DLL Pass value: $func $params \n";
        my $retVal= new Win32::API($MY_DLL,$func,$params,'I');
        croak("Failed to import $func from $MY_DLL \n") if(!$retVal);
        return $retVal;
    }

I have added use Win32::API; and I have defined use constant MY_DLL => 'D:\MyData\MYDLL_CON'; # name of the dll

What I get when I call _import("Init",'P'); ("Init" function which accepts a pointer), Command line prints:

DLL Pass value: Init P Failed to import Init from

Note that there is a < Space > after "from". DLL exists on the path but still it WIN32:API function treats it as blank! Same perl script works on certain machine and doesn't work (gives above error) on certain machine. All machines have same configuration plus same version of Perl and everything. But It finds the DLL on few machines and doesn't on rest!

Dependency Walker doesn't show any dependency errors for the DLL.

I am clueless what's happening!

Swanand
  • 4,027
  • 10
  • 41
  • 69

1 Answers1

0

$MY_DLL is not the same thing as MY_DLL. Get rid of the $.

ikegami
  • 367,544
  • 15
  • 269
  • 518