news.html
来自「perl教程」· HTML 代码 · 共 492 行 · 第 1/3 页
HTML
492 行
<p>
</p>
<h2><a name="new_nothing___function_in_win32__ole__variant">New <code>nothing()</code> function in Win32::OLE::Variant</a></h2>
<p>The <code>nothing()</code> function returns an empty VT_DISPATCH variant. It can be
used to clear an object reference stored in a property</p>
<pre>
<span class="keyword">use</span> <span class="variable">Win32::OLE::Variant</span> <span class="string">qw(:DEFAULT nothing)</span><span class="operator">;</span>
<span class="comment"># ...</span>
<span class="variable">$object</span><span class="operator">-></span><span class="operator">{</span><span class="string">Property</span><span class="operator">}</span> <span class="operator">=</span> <span class="variable">nothing</span><span class="operator">;</span>
</pre>
<p>This has the same effect as the Visual Basic statement</p>
<pre>
Set object.Property = Nothing</pre>
<p>
</p>
<h2><a name="new__newenum_and__unique_options">New _NewEnum and _Unique options</a></h2>
<p>There are two new options available for the Win32::OLE->Option class
method: <code>_NewEnum</code> provides the elements of a collection object
directly as the value of a <code>_NewEnum</code> property. The <code>_Unique</code>
option guarantees that Win32::OLE will not create multiple proxy
objects for the same underlying COM/OLE object.</p>
<p>Both options are only really useful to tree traversal programs or
during debugging.</p>
<p>
</p>
<hr />
<h1><a name="version_0_12">Version 0.12</a></h1>
<p>
</p>
<h2><a name="additional_error_handling_functionality">Additional error handling functionality</a></h2>
<p>The Warn option can now be set to a CODE reference too. For example,</p>
<pre>
<span class="variable">Win32::OLE</span><span class="operator">-></span><span class="variable">Option</span><span class="operator">(</span><span class="string">Warn</span> <span class="operator">=></span> <span class="number">3</span><span class="operator">);</span>
</pre>
<p>could now be written as</p>
<pre>
<span class="variable">Win32::OLE</span><span class="operator">-></span><span class="variable">Option</span><span class="operator">(</span><span class="string">Warn</span> <span class="operator">=></span> <span class="operator">\&</span><span class="variable">Carp::croak</span><span class="operator">);</span>
</pre>
<p>This can even be used to emulate the VisualBasic <code>On Error Goto
Label</code> construct:</p>
<pre>
<span class="variable">Win32::OLE</span><span class="operator">-></span><span class="variable">Option</span><span class="operator">(</span><span class="string">Warn</span> <span class="operator">=></span> <span class="keyword">sub</span><span class="variable"> </span><span class="operator">{</span><span class="keyword">goto</span> <span class="variable">CheckError</span><span class="operator">});</span>
<span class="comment"># ... your normal OLE code here ...</span>
</pre>
<pre>
CheckError:
# ... your error handling code here ...</pre>
<p>
</p>
<h2><a name="builtin_event_loop">Builtin event loop</a></h2>
<p>Processing OLE events required a polling loop before, e.g.</p>
<pre>
<span class="keyword">my</span> <span class="variable">$Quit</span><span class="operator">;</span>
<span class="comment">#...</span>
<span class="keyword">until</span> <span class="operator">(</span><span class="variable">$Quit</span><span class="operator">)</span> <span class="operator">{</span>
<span class="variable">Win32::OLE</span><span class="operator">-></span><span class="variable">SpinMessageLoop</span><span class="operator">;</span>
<span class="variable">Win32::Sleep</span><span class="operator">(</span><span class="number">100</span><span class="operator">);</span>
<span class="operator">}</span>
<span class="keyword">package</span> <span class="variable">BrowserEvents</span><span class="operator">;</span>
<span class="keyword">sub</span><span class="variable"> OnQuit </span><span class="operator">{</span> <span class="variable">$Quit</span> <span class="operator">=</span> <span class="number">1</span> <span class="operator">}</span>
</pre>
<p>This is inefficient and a bit odd. This version of Win32::OLE now
supports a standard messageloop:</p>
<pre>
<span class="variable">Win32::OLE</span><span class="operator">-></span><span class="variable">MessageLoop</span><span class="operator">();</span>
</pre>
<pre>
<span class="keyword">package</span> <span class="variable">BrowserEvents</span><span class="operator">;</span>
<span class="keyword">sub</span><span class="variable"> OnQuit </span><span class="operator">{</span> <span class="variable">Win32::OLE</span><span class="operator">-></span><span class="variable">QuitMessageLoop</span> <span class="operator">}</span>
</pre>
<p>
</p>
<h2><a name="free_unused_ole_libraries">Free unused OLE libraries</a></h2>
<p>Previous versions of Win32::OLE would call the <code>CoFreeUnusedLibraries()</code>
API whenever an OLE object was destroyed. This made sure that OLE
libraries would be unloaded as soon as they were no longer needed.
Unfortunately, objects implemented in Visual Basic tend to crash
during this call, as they pretend to be ready for unloading, when in
fact, they aren't.</p>
<p>The unloading of object libraries is really only important for long
running processes that might instantiate a huge number of <strong>different</strong>
objects over time. Therefore this API is no longer called
automatically. The functionality is now available explicitly to those
who want or need it by calling a Win32::OLE class method:</p>
<pre>
<span class="variable">Win32::OLE</span><span class="operator">-></span><span class="variable">FreeUnusedLibraries</span><span class="operator">();</span>
</pre>
<p>
</p>
<h2><a name="the_win32__ole_article_from_the_perl_journal__10">The "Win32::OLE" article from "The Perl Journal #10"</a></h2>
<p>The article is Copyright 1998 by <em>The Perl
Journal</em>. <a href="http://www.tpj.com">http://www.tpj.com</a></p>
<p>It originally appeared in <em>The Perl Journal</em> # 10 and appears here
courtesy of Jon Orwant and <em>The Perl Journal</em>. The sample code from
the article is in the <em>eg/tpj.pl</em> file.</p>
<p>
</p>
<h2><a name="variant_put___bug_fixes">VARIANT-><code>Put()</code> bug fixes</a></h2>
<p>The <code>Put()</code> method didn't work correctly for arrays of type VT_BSTR,
VT_DISPATH or VT_UNKNOWN. This has been fixed.</p>
<p>
</p>
<h2><a name="error_message_fixes">Error message fixes</a></h2>
<p>Previous versions of Win32::OLE gave a wrong argument index for some
OLE error messages (the number was too large by 1). This should be
fixed now.</p>
<p>
</p>
<h2><a name="vt_date_and_vt_error_return_values_handled_differently">VT_DATE and VT_ERROR return values handled differently</a></h2>
<p>Method calls and property accesses returning a VT_DATE or VT_ERROR
value would previously translate the value to string or integer
format. This has been changed to return a Win32::OLE::Variant object.
The return values will behave as before if the Win32::OLE::Variant
module is being used. This module overloads the conversion of
the objects to strings and numbers.</p>
<p>
</p>
<hr />
<h1><a name="version_0_11__changes_since_0_1008_">Version 0.11 (changes since 0.1008)</a></h1>
<p>
</p>
<h2><a name="new_dhtml_typelib_browser">new DHTML typelib browser</a></h2>
<p>The Win32::OLE distribution now contains a type library browser. It
is written in PerlScript, generating dynamic HTML. It requires
Internet Explorer 4.0 or later. You'll find it in
<em>browser/Browser.html</em>. It should be available in the ActivePerl
HTML help under Win32::OLE::Browser.</p>
<p>After selecting a library, type or member you can press F1 to call up
the corresponding help file at the appropriate location.</p>
<p>
</p>
<h2><a name="vt_decimal_support">VT_DECIMAL support</a></h2>
<p>The Win32::OLE::Variant module now supports VT_DECIMAL variants too.
They are not "officially" allowed in OLE Automation calls, but even
Microsoft's "ActiveX Data Objects" sometimes returns VT_DECIMAL
values.</p>
<p>VT_DECIMAL variables are stored as 96-bit integers scaled by a
variable power of 10. The power of 10 scaling factor specifies the
number of digits to the right of the decimal point, and ranges from 0
to 28. With a scale of 0 (no decimal places), the largest possible
value is +/-79,228,162,514,264,337,593,543,950,335. With a 28 decimal
places, the largest value is +/-7.9228162514264337593543950335 and the
smallest, non-zero value is +/-0.0000000000000000000000000001.</p>
<p>
</p>
<hr />
<h1><a name="version_0_1008">Version 0.1008</a></h1>
<p>
</p>
<h2><a name="new_letproperty___object_method">new <code>LetProperty()</code> object method</a></h2>
<p>In Win32::OLE property assignment using the hash syntax is equivalent
to the Visual Basic <code>Set</code> syntax (<em>by reference</em> assignment):</p>
<pre>
<span class="variable">$Object</span><span class="operator">-></span><span class="operator">{</span><span class="string">Property</span><span class="operator">}</span> <span class="operator">=</span> <span class="variable">$OtherObject</span><span class="operator">;</span>
</pre>
<p>corresponds to this Visual Basic statement:</p>
<pre>
Set Object.Property = OtherObject</pre>
<p>To get the <em>by value</em> treatment of the Visual Basic <code>Let</code> statement</p>
<pre>
Object.Property = OtherObject</pre>
<p>you have to use the <code>LetProperty()</code> object method in Perl:</p>
<pre>
<span class="variable">$Object</span><span class="operator">-></span><span class="variable">LetProperty</span><span class="operator">(</span><span class="variable">$Property</span><span class="operator">,</span> <span class="variable">$OtherObject</span><span class="operator">);</span>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?