/
OLE.pod
executable file
·1975 lines (1358 loc) · 60.1 KB
/
OLE.pod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=encoding euc-jp
=head1 NAME
=begin original
Win32::OLE - OLE Automation extensions
=end original
Win32::OLE - OLE オートメーション拡張
=head1 SYNOPSIS
$ex = Win32::OLE->new('Excel.Application') or die "oops\n";
$ex->Amethod("arg")->Bmethod->{'Property'} = "foo";
$ex->Cmethod(undef,undef,$Arg3);
$ex->Dmethod($RequiredArg1, {NamedArg1 => $Value1, NamedArg2 => $Value2});
$wd = Win32::OLE->GetObject("D:\\Data\\Message.doc");
$xl = Win32::OLE->GetActiveObject("Excel.Application");
=head1 DESCRIPTION
=begin original
This module provides an interface to OLE Automation from Perl.
OLE Automation brings VisualBasic like scripting capabilities and
offers powerful extensibility and the ability to control many Win32
applications from Perl scripts.
=end original
このモジュールは Perl からの OLE オートメーションへのインターフェースを
提供します。
OLE オートメーションは VisualBasic のようなスクリプトの能力を提供し、
強力な拡張性と Perl スクリプトから数多くの Win32 アプリケーションを
制御する能力を提供します。
=begin original
The Win32::OLE module uses the IDispatch interface exclusively. It is
not possible to access a custom OLE interface. OLE events and OCX's are
currently not supported.
=end original
Win32::OLE モジュールはもっぱら IDispatch インターフェースを使用します。
カスタム OLE インターフェースにアクセスすることはできません。
OLE インベントと OCX には現在のところ対応していません。
=begin original
Actually, that's no longer strictly true. This module now contains
B<ALPHA> level support for OLE events. This is largely untested and the
specific interface might still change in the future.
=end original
実際には、これは厳密には正しくありません。
このモジュールは OLE イベントに B<アルファ> レベルで対応しています。
これはあまりテストされていませんし、インタフェース仕様は将来
変更される可能性があります。
=head2 Methods
(メソッド)
=over 8
=item Win32::OLE->new(PROGID[, DESTRUCTOR])
=begin original
The new() class method starts a new instance of an OLE Automation object.
It returns a reference to this object or C<undef> if the creation failed.
=end original
new() クラスメソッドは OLE オートメーションオブジェクトの新しい
インスタンスを開始します。
このオブジェクトのリファレンスか、もし作成が失敗すれば C<undef> を返します。
=begin original
The PROGID argument must be either the OLE I<program id> or the I<class id>
of the required application. The optional DESTRUCTOR specifies a DESTROY-like
method. This can be either a CODE reference or a string containing an OLE
method name. It can be used to cleanly terminate OLE applications in case the
Perl program dies.
=end original
PROGID 引数は必要なアプリケーションの OLE I<プログラム ID> または
I<クラス ID> でなければなりません。
オプションの DESTRUCTOR には DESTROY のようなメソッドを指定します。
これは CODE リファレンスまたは OLE メソッド名の入った文字列のどちらかに
することができます。
これは Perl プログラムが die するときに、OLE アプリケーションを
きれいに終らせるために使われます。
=begin original
To create an object via DCOM on a remote server you can use an array
reference in place of PROGID. The referenced array must contain the
machine name and the I<program id> or I<class id>. For example:
=end original
DCOM を通じてリモートサーバーにオブジェクトを作成するためには、PROGID の
ところに配列リファレンスを使えます。
参照される配列にはマシン名と I<プログラム ID> または I<クラス ID> が
入らなければなりません。
例えば:
my $obj = Win32::OLE->new(['my.machine.com', 'Program.Id']);
=begin original
If the PROGID is a I<program id> then Win32::OLE will try to resolve the
corresponding I<class id> locally. If the I<program id> is not registered
locally then the remote registry is queried. This will only succeed if
the local process has read access to the remote registry. The safest
(and fastest) method is to specify the C<class id> directly.
=end original
PROGID が I<プログラム ID> であれば、Win32::OLE はローカルに対応する
I<クラス ID> を解決しようとします。
もしローカルに I<プログラム ID> が登録されていなければ、リモートレジストリが
問い合わせられます。
これはローカルなプロセスがリモートレジストリに読み込みアクセスを
もっているときにのみ成功します。
もっとも安全な(そしても最も速い)方法は、C<クラス ID> を直接指定することです。
=item Win32::OLE->EnumAllObjects([CALLBACK])
=begin original
This class method returns the number Win32::OLE objects currently in
existance. It will call the optional CALLBACK function for each of
these objects:
=end original
このクラスメソッドは現在存在する Win32::OLE オブジェクトの数を返します。
オプションで各オブジェクトへの CALLBACK 関数を呼ぶこともできます:
$Count = Win32::OLE->EnumAllObjects(sub {
my $Object = shift;
my $Class = Win32::OLE->QueryObjectType($Object);
printf "# Object=%s Class=%s\n", $Object, $Class;
});
=begin original
The EnumAllObjects() method is primarily a debugging tool. It can be
used e.g. in an END block to check if all external connections have
been properly destroyed.
=end original
EnumAllObjects() メソッドは主にデバッグのためのツールです。
これは例えば、すべての外部コメンクションが適切に破壊されているかを
チェックするために END ブロックに入れて使えます。
=item Win32::OLE->FreeUnusedLibraries()
=begin original
The FreeUnusedLibraries() class method unloads all unused OLE
resources. These are the libraries of those classes of which all
existing objects have been destroyed. The unloading of object
libraries is really only important for long running processes that
might instantiate a huge number of B<different> objects over time.
=end original
FreeUnusedLibraries() クラスメソッドは全ての使われていない OLE リソースを
アンロードします。
これらは存在しているオブジェクトのすべてが破壊されたクラスのライブラリです。
オブジェクトライブラリのアンロードは、長時間とても多くの B<異なる>
オブジェクトを繰り返し、インスタンス生成するプロセスを実行したときにだけ
本当に重要です。
=begin original
Be aware that objects implemented in Visual Basic have a buggy
implementation of this functionality: They pretend to be unloadable
while they are actually still running their cleanup code. Unloading
the DLL at that moment typically produces an access violation. The
probability for this problem can be reduced by calling the
SpinMessageLoop() method and sleep()ing for a few seconds.
=end original
Visual Basic で実装されたオブジェクトはこの機能についてバグを
持っているかもしれないことに注意してください。
実際に彼らのクリーンアップコードを実行するまではアンロード可能に
することを拒みます。
その時点でDLLをアンロードすることは典型的には、アクセスバイオレーションを
発生させます。
この問題の可能性は SpinMessageLoop() メソッドを呼び出し、2, 3秒
sleep() することにより減らすことができます。
=item Win32::OLE->GetActiveObject(CLASS[, DESTRUCTOR])
=begin original
The GetActiveObject() class method returns an OLE reference to a
running instance of the specified OLE automation server. It returns
C<undef> if the server is not currently active. It will croak if
the class is not even registered. The optional DESTRUCTOR method takes
either a method name or a code reference. It is executed when the last
reference to this object goes away. It is generally considered C<impolite>
to stop applications that you did not start yourself.
=end original
GetActiveObject() クラスメソッドは指定された OLE オートメーションサーバーの
動いているインスタンスへの OLE リファレンスを返します。
もしサーバーが現在アクティブでなければ、C<undef> を返します。
そのクラス登録さえもしていなければ、croak します。
オプションの DESTRUCTOR メソッドはメソッド名、あるいはコードリファレンスを
とります。
このオブジェクトへの最後のリファレンスが失われるときに実行されます。
一般的にあなたが起動したのではないアプリケーションを止めることは
一般的には無作法だと考えられます。
=item Win32::OLE->GetObject(MONIKER[, DESTRUCTOR])
=begin original
The GetObject() class method returns an OLE reference to the specified
object. The object is specified by a pathname optionally followed by
additional item subcomponent separated by exclamation marks '!'. The
optional DESTRUCTOR argument has the same semantics as the DESTRUCTOR in
new() or GetActiveObject().
=end original
GetObject() クラスメソッドは指定されたオブジェクトへの OLE リファレンスを
返します。
そのオブジェクトはパス名で指定され、オプションで後ろに
エクスクラメーションマーク '!'によって区切られた追加の要素
サブコンポーネントがつきます。
オプションの DESTRUCTOR 引数は new() や GetActiveObject() と
同じ意味を持ちます。
=item Win32::OLE->Initialize([COINIT])
=begin original
The Initialize() class method can be used to specify an alternative
apartment model for the Perl thread. It must be called B<before> the
first OLE object is created. If the C<Win32::OLE::Const> module is
used then the call to the Initialize() method must be made from a BEGIN
block before the first C<use> statement for the C<Win32::OLE::Const>
module.
=end original
Initialize() クラスメソッドは Perl スレッドのための代わりの
アパートメントモデルを指定するために使えます。
これは最初の OLE オブジェクトが作成される B<前> に呼ばれなければなりません。
もし C<Win32::OLE::Const> モジュールが使われていれば、Initialize() メソッドの
呼び出しは最初の C<Win32::OLE::Const> モジュールのための C<use>
ステートメントの前の BEGIN ブロックでされなければなりません。
=begin original
Valid values for COINIT are:
=end original
COINTへの正しい値は以下の通りです:
=begin original
Win32::OLE::COINIT_APARTMENTTHREADED - single threaded
Win32::OLE::COINIT_MULTITHREADED - the default
Win32::OLE::COINIT_OLEINITIALIZE - single threaded, additional OLE stuff
=end original
Win32::OLE::COINIT_APARTMENTTHREADED - シングルスレッド
Win32::OLE::COINIT_MULTITHREADED - デフォルト
Win32::OLE::COINIT_OLEINITIALIZE - シングルスレッド、追加の OLE 機能
=begin original
COINIT_OLEINITIALIZE is sometimes needed when an OLE object uses
additional OLE compound document technologies not available from the
normal COM subsystem (for example MAPI.Session seems to require it).
Both COINIT_OLEINITIALIZE and COINIT_APARTMENTTHREADED create a hidden
top level window and a message queue for the Perl process. This may
create problems with other application, because Perl normally doesn't
process its message queue. This means programs using synchronous
communication between applications (such as DDE initiation), may hang
until Perl makes another OLE method call/property access or terminates.
This applies to InstallShield setups and many things started to shell
associations. Please try to utilize the C<Win32::OLE-E<gt>SpinMessageLoop>
and C<Win32::OLE-E<gt>Uninitialize> methods if you can not use the default
COINIT_MULTITHREADED model.
=end original
COINIT_OLEINITIALIZE は OLE オブジェクトが、通常の COM サブシステムでは
利用できない、追加の OLE コンパウンドドキュメント技術を使っているさいに、
ときおり必要になります(例えば MAPI セッションはこれが必要なようです)。
COINIT_OLEINITIALIZE と COINIT_APARTMENTTHREADED は隠れたトップレベル
ウィンドウと Perl プロセスのためのメッセージキューを作成します。
これは他のアプリケーションとの問題を発生させるかもしれません。
というのも Perl は通常そのメッセージキューを処理しないからです。
つまりアプリケーション間で同期型通信(DDE イニシエーションのような)を
使っているプログラムは Perl が他の OLE メソッド呼び出し/プロパティアクセスを
おこすか、終了するまで止まってしまうかもしれません。
これは InstallShield セットアップやシェル関連から発生する多くの事柄に
あてはまります。
デフォルトの COINIT_MULTITHREADED モデルを使うことができないのであれば、
C<Win32::OLE-E<gt>SpinMessageLoop> と C<Win32::OLE-E<gt>Uninitialize>
メソッドをを使ってみてください。
=item OBJECT->Invoke(METHOD[, ARGS])
=begin original
The Invoke() object method is an alternate way to invoke OLE
methods. It is normally equivalent to C<$OBJECT->METHOD(@ARGS)>. This
function must be used if the METHOD name contains characters not valid
in a Perl variable name (like foreign language characters). It can
also be used to invoke the default method of an object even if the
default method has not been given a name in the type library. In this
case use <undef> or C<''> as the method name. To invoke an OLE objects
native Invoke() method (if such a thing exists), please use:
=end original
Invoke() オブジェクトメソッドは OLE メソッドを呼び出す代替方法です。
これは通常 C<$OBJECT-E<gt>METHOD(@ARGS)> と同じです。
この関数は METHOD 名に Perl 変数名として正しくない文字 (例えば外国の文字) が
入っているときに使わなければなりません。
もしデフォルトのメソッドがライブラリで名前を与えられていなくても、その
オブジェクトのデフォルトのメソッドを呼び出すために使えます。
この場合には C<undef> または C<''> をメソッド名として使います。
OLE オブジェクトネイティブの Invoke() メソッドを (もしそのようなものが
あったとして) 呼び出すためには、以下のようにします:
$Object->Invoke('Invoke', @Args);
=item Win32::OLE->LastError()
=begin original
The LastError() class method returns the last recorded OLE
error. This is a dual value like the C<$!> variable: in a numeric
context it returns the error number and in a string context it returns
the error message. The error number is a signed HRESULT value. Please
use the L<HRESULT(ERROR)> function to convert an unsigned hexadecimal
constant to a signed HRESULT.
=end original
LastError() クラスメソッドは最後に記録された OLE エラーを返します。
これは C<$!> 変数のように二つの値を持ちます: 数値コンテキストでは
エラー番号を返し、文字列コンテキストではエラーメッセージを返します。
エラー番号は符号付きの HRESULT の値です。
符号なしの 16 進定数を符号付きの HRESULT に変換するためには
L<HRESULT(ERROR)> 関数を使ってください。
=begin original
The last OLE error is automatically reset by a successful OLE
call. The numeric value can also explicitly be set by a call (which will
discard the string value):
=end original
最後の OLE エラーは、後の正常な OLE 呼び出しによって自動的にリセットされます。
数値は明示的に呼び出すことによって設定することができます(それは文字列の値を
捨てます):
Win32::OLE->LastError(0);
=item OBJECT->LetProperty(NAME,ARGS,VALUE)
=begin original
In Win32::OLE property assignment using the hash syntax is equivalent
to the Visual Basic C<Set> syntax (I<by reference> assignment):
=end original
Win32::OLE では、ハッシュの書き方を使ったプロパティ設定は Visual Basic の
Set と同じです(I<リファレンスによる> 代入):
$Object->{Property} = $OtherObject;
=begin original
corresponds to this Visual Basic statement:
=end original
これは以下の Visual Basic ステートメントに対応します:
Set Object.Property = OtherObject
=begin original
To get the I<by value> treatment of the Visual Basic C<Let> statement
=end original
Visual Basic の C<Let> ステートメントの I<値による> 扱いを得るには:
Object.Property = OtherObject
=begin original
you have to use the LetProperty() object method in Perl:
=end original
Perl では LetProperty() オブジェクトメソッドを使う必要があります:
$Object->LetProperty($Property, $OtherObject);
=begin original
LetProperty() also supports optional arguments for the property assignment.
See L<OBJECT->SetProperty(NAME,ARGS,VALUE)> for details.
=end original
LetProperty() はプロパティ設定のためのオプションの引数もサポートしています。
詳しくは L<OBJECT-E<gt>SetProperty(NAME,ARGS,VALUE)> を参照してください。
=item Win32::OLE->MessageLoop()
=begin original
The MessageLoop() class method will run a standard Windows message
loop, dispatching messages until the QuitMessageLoop() class method is
called. It is used to wait for OLE events.
=end original
MessageLoop() クラスメソッドは標準の Windows メッセージループを実行し、
QuitMessageLoop() クラスメソッドが呼ばれるまで、メッセージを処理します。
これは OLE イベントを待つために使われます。
=item Win32::OLE->Option(OPTION)
=begin original
The Option() class method can be used to inspect and modify
L<Module Options>. The single argument form retrieves the value of
an option:
=end original
Option() クラスメソッドは L<Module Options> を検査し、変更するために
使えます。
一つだけ引数を指定すると、そのオプションの値を取り出します:
my $CP = Win32::OLE->Option('CP');
=begin original
A single call can be used to set multiple options simultaneously:
=end original
一回の呼び出しで複数のオプションを同時に設定することもできます。
Win32::OLE->Option(CP => CP_ACP, Warn => 3);
=item Win32::OLE->QueryObjectType(OBJECT)
=begin original
The QueryObjectType() class method returns a list of the type library
name and the objects class name. In a scalar context it returns the
class name only. It returns C<undef> when the type information is not
available.
=end original
QueryObjectType() クラスメソッドはタイプライブラリ名と
オブジェクトクラス名のリストを返します。
スカラコンテキストではそれはクラス名だけを返します。
タイプ情報が使えなければ、C<undef> を返します。
=item Win32::OLE->QuitMessageLoop()
=begin original
The QuitMessageLoop() class method posts a (user-level) "Quit" message
to the current threads message loop. QuitMessageLoop() is typically
called from an event handler. The MessageLoop() class method will
return when it receives this "Quit" method.
=end original
QuitMessageLoop() クラスメソッドは(ユーザーレベルで) "Quit" メッセージを
現在のスレッドメッセージループにポストします。
QuitMessageLoop() は典型的にはイベントハンドラから呼ばれます。
MessageLoop() クラスメソッドは、この "Quit" メソッドを受け取ると、戻ります。
=item OBJECT->SetProperty(NAME,ARGS,VALUE)
=begin original
The SetProperty() method allows to modify properties with arguments,
which is not supported by the hash syntax. The hash form
=end original
SetProperty() メソッドはハッシュの書き方をサポートしていないプロパティを
引数の値に変更できます。
ハッシュ形式は以下の通りです
$Object->{Property} = $Value;
=begin original
is equivalent to
=end original
これは以下のものと同じです
$Object->SetProperty('Property', $Value);
=begin original
Arguments must be specified between the property name and the new value:
=end original
引数はプロパティ名と新しい値の間に指定されなければなりません:
$Object->SetProperty('Property', @Args, $Value);
=begin original
It is not possible to use "named argument" syntax with this function
because the new value must be the last argument to SetProperty().
=end original
新しい値は SetProperty() への最後の引数でなければならないので、この関数で
「名前付き引数」の書き方を使うことはできません。
=begin original
This method hides any native OLE object method called SetProperty().
The native method will still be available through the Invoke() method:
=end original
このメソッドは SetProperty() と呼ばれるネイティブな OLE オブジェクト
メソッドを隠してしまいます。
そのネイティブなメソッドは Invoke() メソッドを使って呼び出すことができます:
$Object->Invoke('SetProperty', @Args);
=item Win32::OLE->SpinMessageLoop
=begin original
This class method retrieves all pending messages from the message queue
and dispatches them to their respective window procedures. Calling this
method is only necessary when not using the COINIT_MULTITHREADED model.
All OLE method calls and property accesses automatically process the
message queue.
=end original
このクラスメソッドはすべてのメッセージキューに保留されている
メッセージを取り出し、対応する Windows プロシ-ジャーに処理させます。
このメソッドは COINIT_MULTITHREADED モデルを使っていないときにだけ
必要になります。
すべての OLE メソッド呼び出しとプロパティアクセスは自動的に
メッセージキューを処理します。
=item Win32::OLE->Uninitialize
=begin original
The Uninitialize() class method uninitializes the OLE subsystem. It
also destroys the hidden top level window created by OLE for single
threaded apartments. All OLE objects will become invalid after this call!
It is possible to call the Initialize() class method again with a different
apartment model after shutting down OLE with Uninitialize().
=end original
Uninitialize() クラスメソッドは OLE サブシステムの反初期化をします。
これはシングルスレッド分離のための OLE によって作られた隠れた
トップレベルウィンドウを破壊もします。
これを呼び出した後には、すべての OLE オブジェクトが不適切になります!
Uninitialize() で OLE を終了させた後、再び Initialize() クラスメソッドを
異なる分離モデルで呼び出すことは可能です。
=item Win32::OLE->WithEvents(OBJECT[, HANDLER[, INTERFACE]])
=begin original
This class method enables and disables the firing of events by the
specified OBJECT. If no HANDLER is specified, then events are
disconnected. For some objects Win32::OLE is not able to
automatically determine the correct event interface. In this case the
INTERFACE argument must contain either the COCLASS name of the OBJECT
or the name of the event DISPATCH interface. Please read the L<Events>
section below for detailed explanation of the Win32::OLE event
support.
=end original
このクラスメソッドは OBJECT によって指定されたイベントを発火させるのを
可能にも不可能にもできます。
HANDLER が指定されなければ、イベントは接続されません。
いくつかのオブジェクトでは Win32::OLE は自動的に正しい
イベントインターフェースを判定できません。
その場合、INTERFACE 引数は OBJECT の COCLASS 名またはイベント
DISPATCH インターフェースの名前のどちらかが入っていなければなりません。
Win32::OLE イベントサポートの詳細な説明については下記の
L</Events> セクションをお読みださい。
=back
=begin original
Whenever Perl does not find a method name in the Win32::OLE package it
is automatically used as the name of an OLE method and this method call
is dispatched to the OLE server.
=end original
Perl が Win32::OLE パッケージでメソッド名を見つけられなかった場合、それは
自動的に OLE メソッドの名前として使われます。
そしてこのメソッド呼び出しは OLE サーバーによって処理されます。
=begin original
There is one special hack built into the module: If a method or property
name could not be resolved with the OLE object, then the default method
of the object is called with the method name as its first parameter. So
=end original
このモジュールには一つの特別な方法が組み込まれています。
もしメソッドまたはプロパティ名が OLE オブジェクトによって解決されなければ、
オブジェクトのデフォルトメソッドがそのメソッド名を第1引数として呼ばれます。
そこで
my $Sheet = $Worksheets->Table1;
=begin original
or
=end original
または
my $Sheet = $Worksheets->{Table1};
=begin original
is resolved as
=end original
は以下のように解決されます
my $Sheet = $Worksheet->Item('Table1');
=begin original
provided that the $Worksheets object doesnot have a C<Table1> method
or property. This hack has been introduced to call the default method
of collections which did not name the method in their type library. The
recommended way to call the "unnamed" default method is:
=end original
$Worksheeets オブジェクトが C<Table1> メソッドまたはプロパティを
持っていない場合です。
この方法はタイプライブラリではメソッドに名前をつけないコレクションの
デフォルトメソッドを呼び出すために導入されています。
「名無しの」デフォルトメソッドを呼び出す推奨される方法は以下の通りです:
my $Sheet = $Worksheets->Invoke('', 'Table1');
=begin original
This special hack is disabled under C<use strict 'subs';>.
=end original
この特殊な方法は C<use strict 'subs'> の元では使えません。
=head2 Object methods and properties
(オブジェクトメソッドとプロパティ)
=begin original
The object returned by the new() method can be used to invoke
methods or retrieve properties in the same fashion as described
in the documentation for the particular OLE class (eg. Microsoft
Excel documentation describes the object hierarchy along with the
properties and methods exposed for OLE access).
=end original
new() メソッドによって返されるオブジェクトは、特定の OLE クラスのための
ドキュメントで説明されているのと同じ形式で、メソッドを呼び出したり、
プロパティを取り出したりするのに使えます。
(例えば Microsoft Excel ドキュメントは OLE アクセスのために公開されている
プロパティやメソッドを持ったオブジェクト階層について説明しています)。
=begin original
Optional parameters on method calls can be omitted by using C<undef>
as a placeholder. A better way is to use named arguments, as the
order of optional parameters may change in later versions of the OLE
server application. Named parameters can be specified in a reference
to a hash as the last parameter to a method call.
=end original
メソッド呼び出しでのオプションのパラメータは C<undef> をプレースホルダとして
使うことによって省略できます。
オプションのパラメータの順序は OLE サーバーアプリケーションの後の
バージョンでは変更されてしまうかもしれないので、よりよい方法は名前付き
引数を使うことです。
名前付きパラメータはハッシュへのリファレンスをメソッド呼び出しのへの
最後のパラメータとして指定することでできます。
=begin original
Properties can be retrieved or set using hash syntax, while methods
can be invoked with the usual perl method call syntax. The C<keys>
and C<each> functions can be used to enumerate an object's properties.
Beware that a property is not always writable or even readable (sometimes
raising exceptions when read while being undefined).
=end original
プロパティはハッシュの書き方を使って取得、設定できます。
メソッドは通常のperlメソッド呼び出しの書き方で呼び出すことができます。
C<keys> と C<each> 関数はオブジェクトのプロパティを列挙するために
使えます。
プロパティは常に書込可能そして、読込可能でさえあるわけではないことに
注意してください
(時には未定義である間は読み込んだときに例外を起こすこともあります)。
=begin original
If a method or property returns an embedded OLE object, method
and property access can be chained as shown in the examples below.
=end original
もしメソッドやプロパティが埋め込まれた OLE オブジェクトを返すのであれば、
メソッドとプロパティアクセスは以下の例にあるようにチェーンされます。
=head2 Functions
(関数)
=begin original
The following functions are not exported by default.
=end original
以下の関数はデフォルトではエクスポートされません。
=over 8
=item HRESULT(ERROR)
=begin original
The HRESULT() function converts an unsigned number into a signed HRESULT
error value as used by OLE internally. This is necessary because Perl
treats all hexadecimal constants as unsigned. To check if the last OLE
function returned "Member not found" (0x80020003) you can write:
=end original
HRESULT() 関数は符号なしの数値を符号付きの OLE によって内部的に使われるような
HRESULT エラー値に変換します。
これは Perl が全ての 16 進数定数を符号なしとして扱うために必要です。
最後の OLE 関数が "Member not found" (0x80020003) を返したかどうかを
チェックしたければ、以下のようにすることができます:
if (Win32::OLE->LastError == HRESULT(0x80020003)) {
# your error recovery here
}
=item in(COLLECTION)
=begin original
If COLLECTION is an OLE collection object then C<in $COLLECTION>
returns a list of all members of the collection. This is a shortcut
for C<Win32::OLE::Enum->All($COLLECTION)>. It is most commonly used in
a C<foreach> loop:
=end original
もし COLLECTION が OLE コレクンションオブジェクトであれば、
C<in $COLLECTION> は、そのコレクションのすべての要素のリストを返します。
これは C<Win32::OLE::Enum-E<gt>All($COLLECTION)> のショートカットです。
これは一般的に C<foreach> ループで使われます:
foreach my $value (in $collection) {
# do something with $value here
}
=item valof(OBJECT)
=begin original
Normal assignment of Perl OLE objects creates just another reference
to the OLE object. The valof() function explictly dereferences the
object (through the default method) and returns the value of the object.
=end original
Perl OLE オブジェクトの通常の代入は他の OLE オブジェクトへの他の
リファレンスを作成します。
valof() 関数は明示的にオブジェクト(デフォルトメソッドを通じた)と
オブジェクトの値を区別します。
my $RefOf = $Object;
my $ValOf = valof $Object;
$Object->{Value} = $NewValue;
=begin original
Now $ValOf still contains the old value wheras $RefOf would
resolve to the $NewValue because it is still a reference to
$Object.
=end original
いまや $ValOf はまだ古い値を持っているのに、$RefOf はまだ $Object への
リファレンスなので、$NewValue を解決します。
=begin original
The valof() function can also be used to convert Win32::OLE::Variant
objects to Perl values.
=end original
valof() 関数は Win32::OLE::Variant オブジェクトを Perl 変数に
変換するためにも使えます。
=item with(OBJECT, PROPERTYNAME => VALUE, ...)
=begin original
This function provides a concise way to set the values of multiple
properties of an object. It iterates over its arguments doing
C<$OBJECT->{PROPERTYNAME} = $VALUE> on each trailing pair.
=end original
この関数はあるオブジェクトの複数のプロパティを設定するための簡単な方法を
提供します。
これは後ろについている各組合わせに対して
C<$OBJECT-E<gt>{PROPERTYNAME} = $VALUE> を繰り返しおこないます。
=back
=head2 Overloading
(オーバーロード)
=begin original
The Win32::OLE objects can be overloaded to automatically convert to
their values whenever they are used in a bool, numeric or string
context. This is not enabled by default. You have to request it
through the OVERLOAD pseudoexport:
=end original
Win32::OLE オブジェクトはブール値、数値、文字列コンテキストで
使われたときにはいつでも、自動的にそれらの値に変換するために
オーバーロードできます。
これはデフォルトでは可能ではありません。
OVERLOAD 疑似エクスポートを通して要求する必要があります:
use Win32::OLE qw(in valof with OVERLOAD);
=begin original
You can still get the original string representation of an object
(C<Win32::OLE=0xDEADBEEF>), e.g. for debugging, by using the
C<overload::StrVal()> method:
=end original
例えばデバッグのために C<overload::StrVal()> メソッドを使って、元の
オブジェクトの文字列表現 (C<Win32::OLE=0xDEADBEEF>) を取得することもできます:
print overload::StrVal($object), "\n";
=begin original
Please note that C<OVERLOAD> is a global setting. If any module enables
Win32::OLE overloading then it's active everywhere.
=end original
C<OVERLOAD> はグローバルな設定であることに注意してください。
もしなんらかのモジュールが Win32::OLE オーバーロードを可能にすると、
それはいつでも有効です。
=head2 Events
(イベント)
=begin original
The Win32::OLE module now contains B<ALPHA> level event support. This
support is only available when Perl is running in a single threaded
apartment. This can most easily be assured by using the C<EVENTS>
pseudo-import:
=end original
Win32::OLE モジュールは今は B<アルファ> レベルのイベントサポートを
持っています。
このサポートは Perl がシングルスレッド分離レベルで実行しているときにだけ
利用できます。
これはとても簡単に C<EVENTS> 疑似インポートを使うことによって、
保証することができます:
use Win32::OLE qw(EVENTS);
=begin original
which implicitly does something like:
=end original
これは暗黙のうちに以下のようなことをしています:
use Win32::OLE;
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
=begin original
The current interface to OLE events should be considered experimental
and is subject to change. It works as expected for normal OLE
applications, but OLE control events often don't seem to work yet.
=end original
現在の OLE イベントへのインターフェースは実験的なものであると考えられ、
変更されやすいものです。
通常の OLE アプリケーションでは予定通りに機能しますが、OLE 制御イベントは
まだうまく機能していないようです。
=begin original
Events must be enabled explicitly for an OLE object through the
Win32::OLE->WithEvents() class method. The Win32::OLE module uses the
IProvideClassInfo2 interface to determine the default event source of
the object. If this interface is not supported, then the user must
specify the name of the event source explicitly in the WithEvents()
method call. It is also possible to specify the class name of the
object as the third parameter. In this case Win32::OLE will try to
look up the default source interface for this COCLASS.
=end original
イベントは Win32::OLE->WithEvents() クラスメソッドを通して、
OLE オブジェクトのために明示的に可能にされなければなりません。
Win32::OLE モジュールはオブジェクトのデフォルトイベントソースを
判定するために IProvideClassInfo2 インターフェースを利用しています。
このインターフェースがサポートされていなければ、ユーザは
WithEvents() メソッドで明示的にイベントソースの名前を
指定しなければなりません。
オブジェクトのクラス名を 3 番目のパラメータとして指定することも可能です。
この場合、Win32::OLE は、この COCLASS のための
デフォルトソースインターフェースを見つけようとします。
=begin original