English 中文(简体)
有可能从PERL创建的DLLL网络中找到一种方法?
原标题:It is possible to call a method from a DLL Created in .NET from PERL?
  • 时间:2012-01-12 16:54:20
  •  标签:
  • .net
  • perl
  • dll

我用5.8 和5.8 PERL ,没有找到一种办法,以每公升pkcs #8的形式读到私人基调,因此,我试图在C粉中制造一桶可以做的炮弹,这样我就可以从那里找到方法。

我认为,这样做的单元是:

Win32:API

他们举出的例子就是:

  use Win32::API;
  $function = Win32::API->new(
       mydll,  int sum_integers(int a, int b) ,
  );
  $return = $function->Call(3, 2);

The problem is that in the example I can have direct access to the function sum_integers but How can I call my function sum() with this structure from PERL?:

namespace testCreateDLLToUseInPERL
{
    public class Test
    {
        public Test(){
        }

        public int sum(int n1, int n2)
        {
            return n1 + n2;
        }
    }
}

我尝试:

 Win32::API::Struct->typedef( Test => qw{  });
 Win32::API->Import( testCreateDLLToUseInPERL ,  Test::sum(int a, int b) );
 my $myObj = Win32::API::Struct->new( Test );
 print Dumper($myObj );

上述法典没有发出信息:

该系统无法找到已进入的环境选择

  $function = Win32::API->new(
       testCreateDLLToUseInPERL ,  int sum(int a, int b) ,
  );
  print Dumper($function);
  print Win32::FormatMessage( Win32::GetLastError() );
  $return = $function->Call(3, 2);
  print $return;

上述法典没有发出信息:

无法找到具体程序

因此,我的理解是,DLL是正确的载荷,但我没有为履行这一职能提供适当的途径。

任何想法?

问题回答

<编码> Win:API/code。 说本地的Win32方法是好的,但可以说。 因此,您需要通过<代码>。 Win32:OLE。 您还需要通过<代码>regasm在COM中登记互联网的物体。 http://www.perlmonks.org/?node_id=392275“rel=“nofollow”>is up on perlmonks (尽管这日期是2004年,但情况可能已经改变),但这是一个起点。





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签