문제

다소 이상한 경험. ActiveState의 최신 PDK (v7.3)를 사용하여 Perlctrl을 사용하여 com dll을 만들었습니다. Perlctrl은 장애없이 달렸다. Oleview typelib 괜찮아요. Regsvr32는 괜찮습니다. 그러나 ... 레지스트리에는 징후가 없으며 사용하려고하는 것은 실패합니다. 나는 Regedit을 사용하여 다양한 UID를 사냥했고 그들은 거기에 없습니다.

코드는 다음과 같습니다. lingua :: zh :: WordSegmenter의 포장이지만 인코딩이 GBK가 아닌 UTF8로 변경되었습니다.

아마 분명한 것일 것입니다 ...

package ZHWordSeg;

use strict;
use warnings;
use utf8;
use ws;

use Encode;

use constant STX => chr( 2 ); #[
use constant ETX => chr( 3 ); #]
use constant FS => chr( 28 ); #^
use constant RS => chr( 30 ); #~

use constant TAB_SEPARATOR => 0;
use constant CARET_SEPARATOR => 1;
use constant FS_SEPARATOR => 2;
use constant SPACE_SEPARATOR => 3;
use constant AS_ARRAY => 4;

use feature 'switch';

our $segmenter; 

sub ZHWordSeg_Setup {
  my $dic = shift;
  my $dic_encoding = shift;
  my $separator = shift;
  my $verbose = shift;

  $dic_encoding = 'utf8' unless defined( $dic_encoding );
  $separator = " " unless defined( $separator );
  $verbose = 0 unless defined( $verbose );

  if ( defined( $dic ) ) {
    $segmenter = ws->new( dic => $dic, dic_encoding => $dic_encoding, seperator => $separator, verbose => $verbose );
  } else {
    $segmenter = ws->new( dic_encoding => $dic_encoding, seperator => $separator, verbose => $verbose );
  }
}

sub ZHWordSeg {
  my $source = shift;
  print STDERR $source;
  my $sepcode = shift;
  $source = encode("utf8",$source);
  my $stringres = $segmenter->seg($source);
  my @arrayres;

  given ($sepcode) {
    when (TAB_SEPARATOR) { 
      $stringres =~ tr/ /\t/;
      return $stringres;
    }
    when (CARET_SEPARATOR) { 
      $stringres =~ tr/ /^/;
      $stringres .= "^";
      return $stringres;
    }
    when (FS_SEPARATOR) { 
      $stringres =~ s/ /FS/eg;
      $stringres .= FS;
      return $stringres;
    }
    when (SPACE_SEPARATOR) { 
      return $stringres;
    }
    default { 
      @arrayres = split( / /, $stringres );
      return \@arrayres;
    }
  }
}

sub SetDictionary {
  my ($source) = shift;
  my $res = set_dic($source);
  return $res;
}

1;

=pod

=begin PerlCtrl

%TypeLib = (
  PackageName     => 'ZHWordSeg',
  DocString       => 'Chinese word segmentation',
  HelpContext     => 1,
  TypeLibGUID     => '{F6C9BD66-7CA1-4610-B77F-E219A7122C18}', # do NOT edit this line
  ControlGUID     => '{45D47C6A-2B9A-4D62-9CFD-F18C95DC00C5}', # do NOT edit this line either
  DispInterfaceIID=> '{007E4E7A-3B75-4DC3-864C-7746860941B3}', # or this one
  ControlName     => 'BOCWS',
  ControlVer      => 2,  # increment if new object with same ProgID
  # create new GUIDs as well
  ProgID          => 'ZHWordSeg.BOCWS',
  LCID            => 0,
  DefaultMethod   => 'ChineseWordSegmenter',
  Methods         => {
      'ChineseWordSegmenter' => {
        RetType             =>  VT_VARIANT,
        TotalParams         =>  2,
        NumOptionalParams   =>  1,
        ParamList           =>  
          [ 'source' => VT_BSTR,
            'sepcode' => VT_I4
          ] 
      },
      'ChineseWordSegmenter_Setup' => {
        RetType             =>  VT_VARIANT,
        TotalParams         =>  4,
        NumOptionalParams   =>  4,
        ParamList           =>  
          [ 'dic' => VT_BSTR,
            'dic_encoding' => VT_BSTR,
            'separator' => VT_BSTR,
            'verbose' => VT_BSTR
          ] 
      }
  },  # end of 'Methods'
  Properties        => {
    TAB_SEPARATOR => {
      DocString  => "Separate items with TAB (0x0)",
      Type => VT_I4, 
      DispID => 3,
      ReadOnly => 1,
    },
    CARET_SEPARATOR => {
      DocString  => "Separate items with ^ (0x1)",
      Type => VT_I4, 
      DispID => 4,
      ReadOnly => 1,
    },
    FS_SEPARATOR => {
      DocString  => "Separate items with ascii 28 (0x2)",
      Type => VT_I4, 
      DispID => 5,
      ReadOnly => 1,
    },
    SPACE_SEPARATOR => {
      DocString  => "Separate items with space (0x3)",
      Type => VT_I4, 
      DispID => 6,
      ReadOnly => 1,
    },
    AS_ARRAY => {
      DocString  => "Separate items as array (0x4)",
      Type => VT_I4, 
      DispID => 7,
      ReadOnly => 1,
    }
  },  # end of 'Properties'
);  # end of %TypeLib

=end PerlCtrl

=cut

중요한 경우 .perlctrl 파일입니다.

#!C:\Program Files\ActiveState Perl Dev Kit 7.3 Deployment\bin\lib\pai.exe
PAP-Version: 1.0
Packer: C:\Program Files\ActiveState Perl Dev Kit 7.3 Deployment\bin\perlctrl.exe
Script: ZHWordSeg.ctrl
Cwd: P:\BOCWS
Byref: 0
Clean: 0
Date: 2008-10-24 18:05:42
Debug: 127.0.0.1:2000
Dependent: 0
Dyndll: 0
Exe: BOCWS.dll
Force: 1
Gui: 0
Hostname: xi
No-Compress: 0
No-Gui: 0
No-Logo: 0
Runlib: 
Shared: none
Singleton: 0
Tmpdir: 
Verbose: 0
Version-Comments: 
Version-CompanyName: 
Version-FileDescription: Wrapper of Lingua::ZH::WordSegmenter.pm
Version-FileVersion: 1.0
Version-InternalName: ZHWordSeg
Version-LegalCopyright: 
Version-LegalTrademarks: 
Version-OriginalFilename: ZHWordSeg.ctrl
Version-ProductName: BOChineseWordSegmenter
Version-ProductVersion: 1.0
Warnings: 0
Xclude: 1
도움이 되었습니까?

해결책

유일한 "해결책"내가 찾은 것은 뉴스 : comp.os.ms-windows.programmer.win32에서 제안되었습니다.

저는 PDK 사용자가 아니지만 경험에서 DLLREGISTER 내보내기 코드와 내부적으로 수행하는 작업을 확인해야한다고 말할 수 있습니다. 이것이 regsvr32 호출 이므로이 코드는 COM 서버/프록시의 레지스트리 키를 생성하기 때문입니다. 등, ...

Regmon 또는 Procmon과 같은 sysinternal 도구로 변경 사항을 추적 할 수 있습니다.

궁극적으로, 나는 포기하고 효과가 있었고 그것을 조정 한 이전 버전으로 돌아갔습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top