OLE is a COM-based technology. OLE allows applications to access their components and functions using the general interface provided by other applications. Use the Win32 :: OLE module in Perl to implement support for OLE objects. Application (or DLL dynamic link library) that implements an Automation interface is called Automation Server. The application created and used using the Automation interface is called Automation Controller or Automation Client. Many applications, such as Microsoft Word, Excel, Access, and other Office applications, etc., have implemented an Automation interface. Automation is widely used in ASP, CGI scripts, with ADO technology to access a Data Respository. In order to create an Automation object, Automation Server needs to register himself in the system. In general, an application is installed, it has been helped you have made this step. Of course, even if you don't, you can also use the tools such as Regsrv32.exe to manually register your application. This will insert an entry in the system's registry to tell COM how to find this component, which provides what type of interface, what type of Automation Server is. You can find the Automation objects about it in an application's documentation, as well as related information. Use Perl syntax to create such objects and access it. The following is the basic functional module associated with Automation. Win32 :: OLE provides Perl to the most important support for Ole Automation technology. With this module, you can create and use the Automation object, call the object's method, and configure the properties of the object. Win32 :: OLE :: Enum Create a Collections object and provides an item that enumerates. Win32 :: ole :: Variant allows you to convert the relevant data types into the Variant data type in the OLE. Win32 :: Const imports the constant of the Automation object into your perl script. Note: Win32 :: Ole does not currently support OCXS and OLE events. Win32 :: OLE only implements the IDispatch interface, so it still cannot access a customized OLE interface. 1. Creating an object Automation object replaces an instance of a Win32 :: OLE object in Perl. Win32 :: OLE provides three builders to create a registered Automation object.
New getActiveObject getObject2. Automation method and properties Once you have created an Automation object, you can call the object's method, if you need you to adjust the properties of the object. Automation object method calls with Perl syntax to represent: $ OBJ-> Some_Method (args); Automation object method usually requires many parameters. If you don't want any parameters, you can replace it with undef in the parameter table. $ xl-> Workbooks (1) -> Saves ($ F, undef, undef, undef, undef, 1, undef, undef, 1); you can also use a reference to a HASH hash with named parameters to be used as parameters . The above example can also be written like this: $ xl-> workbooks (1) -> SaveAs ($ f, {addtomru => 1, createbackup => 1}); the properties of the Automation object can be accessed with the Hash symbol. For example: $ value = $ obj -> {"property"}; $ obj -> {"property"} = $ value; you can also enumerate an Automation property, with the following method: $ xl = Win32 :: OLE -> New ("Excel.Application"); While ($ key, $ value) = Each% $ l) {print "$ key = $ value / n";} 2. Win32 :: OLE method Win32 :: OLE There are some other ways to process the Automation interface. These methods are not the method defined by Automation, although they seem to look. If a method is not defined in Win32 :: OLE, then method call is passed to the Automation object. If Automation objects are not defined. Then you will get an OLE error. Here is the method defined in Win32 :: OLE. Invoke LastError QueryObjectType3. Win32 :: OLE Function The following is a function defined in Win32 :: OLE. It is not exported by default.
IN VALOF WITH. WIN32 :: OLE Class Variable Win32 :: OLE Defines certain class variables to configure the default behavior used by Automaion. $ WIN32 :: OLE :: CP Determines the CodePage converted between Perl strings and Automation interface Unicode. The default is CP_ACP, identifies ANSI CODEPAGE. $ WIN32 :: OLE :: LCID Controls all the Locale Identifier called for. Its default is set to Local_neutral. $ WIN32 :: OLE :: Warn Defines the behavior of Win32 :: OLE when an error occurs.