<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1632085368384154" crossorigin="anonymous"></script><script src="https://autohotkey.top/gtag.js"></script></head> <body> <h1>ComObjCreate() <span class="ver">[AHK_L 53+]</span></h1> <p>创建 COM 对象.</p> <pre class="Syntax">ComObject := <span class="func">ComObjCreate</span>(CLSID <span class="optional">, IID</span>)</pre> <h2 id="Parameters">参数</h2> <dl> <dt>CLSID</dt> <dd><p>要创建的 COM 对象的 CLSID 或可读 Prog ID.</p></dd> <dt>IID</dt> <dd><p><span class="ver">[v1.0.96.00+]:</span> 对象支持的接口标识符.</p></dd> </dl> <h2 id="Return_Value">返回值</h2> <p>失败时, 函数可能会抛出异常, 退出脚本或返回空字符串, 具体取决于当前的 <a href="ComObjError.htm">ComObjError()</a> 设置和<a href="ComObjError.htm#factors">其他因素</a>.</p> <p>如果指定了 IID, 则返回接口指针. 不再使用指针时通常脚本必须调用 <a href="ObjAddRef.htm">ObjRelease()</a>.</p> <p>否则, 返回脚本可以使用的包装器对象. 请参阅<a href="../Objects.htm#Usage_Objects">对象语法</a>.</p> <h2 id="Related">相关</h2> <a href="ComObjGet.htm">ComObjGet()</a>, <a href="ComObjActive.htm">ComObjActive()</a>, <a href="ComObjConnect.htm">ComObjConnect()</a>, <a href="ComObjArray.htm">ComObjArray()</a>, <a href="ComObjError.htm">ComObjError()</a>, <a href="ComObjQuery.htm">ComObjQuery()</a>, <a href="http://msdn.microsoft.com/en-us/library/dcw63t7z.aspx">CreateObject (MSDN)</a> <h2 id="Examples">示例</h2> <p>参阅后面的论坛主题可以看到不断增长的示例列表: <a href="https://www.autohotkey.com/forum/topic61509.html">https://www.autohotkey.com/forum/topic61509.html</a>.</p> <div class="ex" id="ExIE"> <p><a class="ex_number" href="#ExIE"></a> 启动 Internet Explorer 实例, 使其可见并导航到一个网站.</p> <pre>ie := ComObjCreate("InternetExplorer.Application") ie.Visible := true <em>; 已知此语句在 IE7 上无法正常执行.</em> ie.Navigate("https://www.autohotkey.com/") </pre> </div> <a href="https://dftg.net">dftg</a><!-- Cloudflare Pages Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "d5a9c4fcb9b6482fa53ce820d892f969"}'></script><!-- Cloudflare Pages Analytics --><script defer src="https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon='{"rayId":"93dfd8de888a6160","version":"2025.4.0-1-g37f21b1","r":1,"serverTiming":{"name":{"cfExtPri":true,"cfL4":true,"cfSpeedBrain":true,"cfCacheStatus":true}},"token":"51750bb5dc4f40cc91a5ec55c63bbc01","b":1}' crossorigin="anonymous"></script> </body> </html>