﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-空穴来风-随笔分类-Python</title><link>http://www.cppblog.com/bigsml/category/7907.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 26 Oct 2008 11:03:56 GMT</lastBuildDate><pubDate>Sun, 26 Oct 2008 11:03:56 GMT</pubDate><ttl>60</ttl><item><title>Python 操作黑莓(Blackberry)通信录</title><link>http://www.cppblog.com/bigsml/archive/2008/10/03/63207.html</link><dc:creator>泡泡牛</dc:creator><author>泡泡牛</author><pubDate>Fri, 03 Oct 2008 14:18:00 GMT</pubDate><guid>http://www.cppblog.com/bigsml/archive/2008/10/03/63207.html</guid><wfw:comment>http://www.cppblog.com/bigsml/comments/63207.html</wfw:comment><comments>http://www.cppblog.com/bigsml/archive/2008/10/03/63207.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/bigsml/comments/commentRss/63207.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bigsml/services/trackbacks/63207.html</trackback:ping><description><![CDATA[为了给黑莓导入iPhone 的通信录(contacts) , 只能利用黑莓的桌面管理器, 通过ipd 来维护. <br>但是发现 ABC Amber BlackBerry Converter 只能转换而无法修改, IPDManager 只能维护铃声和音乐啥的:(&nbsp; 只能自己写了个小程序 <br><br>ipd 的格式可以在 <a href="http://na.blackberry.com/eng/developers/resources/journals/jan_2006/ipd_file_format.jsp">http://na.blackberry.com/eng/developers/resources/journals/jan_2006/ipd_file_format.jsp</a>&nbsp;这里找到, 后面是代码, 只是生成datablock 列表, 还需要额外拷贝. 操作时最好只同步通信录. <br><br>下面是代码 <br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008000">#</span><span style="COLOR: #008000">!/usr/local/bin/python2.5&nbsp;</span><span style="COLOR: #008000"><br>#</span><span style="COLOR: #008000">-*-&nbsp;coding:&nbsp;gbk&nbsp;-*-</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;struct&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;<br><br></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;BBFile:&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">__init__</span><span style="COLOR: #000000">(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">pass</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000">&nbsp;_contactblock(self,&nbsp;name,&nbsp;phone,&nbsp;uid):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">''</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;name&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;name.encode(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">utf-16be</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&lt;HB</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;len(name)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">0xa0</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&lt;B</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">0x01</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;ff&nbsp;*&nbsp;8&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&lt;HB</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">0x54</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">\xff</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;uid&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&lt;HBI</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">0x55</span><span style="COLOR: #000000">,&nbsp;uid)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;phone</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;phone&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;phone.encode(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">gbk</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&lt;HB</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;len(phone)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">0x08</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;phone&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">\x00</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;s&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000">&nbsp;save(self,&nbsp;filename,&nbsp;us,&nbsp;dbID</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0,&nbsp;dbVer</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hf&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;open(filename,&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">w+b</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs,&nbsp;uid&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">363797835</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;初始值</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;u&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;us:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;self._contactblock(u[0],&nbsp;u[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">],&nbsp;uid)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&lt;HIBHI</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;dbID,&nbsp;len(s)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">,&nbsp;dbVer,&nbsp;rs,&nbsp;uid)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hf.write(h&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;s)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uid&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs&nbsp;&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hf.close()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">__name__</span><span style="COLOR: #000000">==</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__main__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br>&nbsp;&nbsp;&nbsp;&nbsp;bb&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;BBFile()<br>&nbsp;&nbsp;&nbsp;&nbsp;us&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;[&nbsp;(u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">宝宝1</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">13888888888</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">),(u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">宝宝2</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">13888888888</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">),(u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">宝宝3</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">13888888888</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">),&nbsp;&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;bb.save(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">bb.ipd</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;us,&nbsp;0,&nbsp;0)<br></span></div>
1. 保存成文件就可以直接运行了:) <br>2. 如果要真的生成可以导入bb 的文件的话, 要使用高级-&gt; 只同步通讯录, 然后将这个文件生成的内容放在导出文件的头的后面, 还是有点麻烦.... 有空做个全自动的 呵呵&nbsp;&nbsp;&nbsp;<br><br>因为只是测试, 所以很多硬编码了:)&nbsp;&nbsp;&nbsp;&nbsp;<br><br>
<img src ="http://www.cppblog.com/bigsml/aggbug/63207.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bigsml/" target="_blank">泡泡牛</a> 2008-10-03 22:18 <a href="http://www.cppblog.com/bigsml/archive/2008/10/03/63207.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在 C++ 中使用 Python script </title><link>http://www.cppblog.com/bigsml/archive/2008/08/14/58859.html</link><dc:creator>泡泡牛</dc:creator><author>泡泡牛</author><pubDate>Thu, 14 Aug 2008 09:55:00 GMT</pubDate><guid>http://www.cppblog.com/bigsml/archive/2008/08/14/58859.html</guid><wfw:comment>http://www.cppblog.com/bigsml/comments/58859.html</wfw:comment><comments>http://www.cppblog.com/bigsml/archive/2008/08/14/58859.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/bigsml/comments/commentRss/58859.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bigsml/services/trackbacks/58859.html</trackback:ping><description><![CDATA[<p>想要在c++ 中嵌入script 代码, 除了自己写脚本引擎外, lua, python 都可以在c++ 中使用, 另外 <a href="http://dev.kalimdor.org/entropia">MonoBind</a>, AngelScript library 都是一些c++ script library, 可以嵌入到c++ 中使用 . <br>今天在c++ 中试着嵌入 python 代码 (示例代码在 Python-2.5.2\Demo\embed\ 下) </p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Python.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;argc,&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">argv[])<br>{<br>&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;Py_NoSiteFlag&nbsp;=&nbsp;1;<br>&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;Py_SetPythonHome("D:\\usr\\Python");&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;PYTHONHOME</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br>&nbsp;&nbsp;Py_Initialize();<br>&nbsp;&nbsp;PyRun_SimpleString(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">from&nbsp;time&nbsp;import&nbsp;time,ctime\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">print&nbsp;'Today&nbsp;is',ctime(time())\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;Py_Finalize();<br>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div>
<p>在运行时可能会产生类似 <strong>'import site' failed; use -v for traceback</strong> 的错误, 原因是python 在import module 的时候的路径问题. 有3种方法可以解决(以前通过设置环境变量 PYTHONPATH 好像在2.5 已经无效了). <br>0. 取消注释 <font color=#008000>Py_NoSiteFlag&nbsp;=&nbsp;1; </font><br>这个只是取消import site , 当然如果在代码中要import 啥的话, 还是会出现错误的. <br>a. 设置环境变量 PYTHONHOME = D:\usr\Python&nbsp; <br>b. 在调用 Py_Initialize 之前调用函数 <br>Py_SetPythonHome("D:\\usr\\Python");&nbsp; // 参数是python 的安装目录 <br><br><strong>2. 其他一些有用的资源</strong> <br><a href="http://docs.python.org/api/api.html">Python/C API Reference Manual</a>&nbsp;(API 参考) ,&nbsp; <a href="http://docs.python.org/ext/ext.html">Extending and Embedding the Python Interpreter</a>&nbsp;(扩展及嵌入Python解释器, 主要说明了如何扩展Python, 给Python 写扩展, 其中 <a href="http://docs.python.org/ext/embedding.html">5. Embedding Python in Another Application&nbsp; </a>一章讲述了在C++中嵌入/调用Python 代码 ) <br><br><a href="http://gashero.yeax.com/?p=38">使用C/C++扩展Python</a>&nbsp; 对文 Extending and Embedding the Python Interpreter 作了精简, 很不错的一篇文章, 但是跳过了一些基础&nbsp;. <br><br><a href="http://www.ddj.com/cpp/184401666">Building Hybrid Systems with Boost.Python</a>&nbsp;介绍了使用boost.python 方便python 插件开发, <a href="http://www.cnblogs.com/xiaotie/archive/2006/02/22/335633.html">python绑定c++程序</a>&nbsp;是其中文版本. <br><br><a href="http://www.linuxjournal.com/article/3641">Embedding Python in Multi-Threaded C/C++ Applications</a>&nbsp;讲了c++在多线程环境如何使用Python , 文&nbsp;<a href="http://blog.csdn.net/liguangyi/archive/2007/06/20/1659697.aspx">C++多线程中调用python api函数</a> 提供了一个多线程的封装. <br><br>SCXX - A Simple Python/C++ API<br><a href="http://davidf.sjsoft.com/mirrors/mcmillan-inc/scxx.html">http://davidf.sjsoft.com/mirrors/mcmillan-inc/scxx.html</a></p>
<p>C++扩展和嵌入Python应用 (介绍了一些Python/C API 函数, 以及ext 例子, 一般般) <br><a href="http://hi.baidu.com/yunsweet/blog/item/20b08aeebaa2b1282cf534c7.html">http://hi.baidu.com/yunsweet/blog/item/20b08aeebaa2b1282cf534c7.html</a></p>
<p><br><strong>3. Python 多线程的使用</strong> <br><br>zz <a href="http://blog.csdn.net/liguangyi/archive/2007/06/20/1659697.aspx">http://blog.csdn.net/liguangyi/archive/2007/06/20/1659697.aspx</a>&nbsp;<br>今天看了近一天关于多线程的应用中，如何安全调用python方面的资料，开始的时候看的简直头大如斗，被python语言的全局锁(Global Interpreter Lock)、线程状态(Thread State )等都有点绕晕了，后来经过各方面文章和帮助文档的相互参考，发现对于2.4/2.5版本，提供了PyGILState_Ensure, PyGILState_Release，哎，这下可方便大发了。</p>
<p>一、首先定义一个封装类，主要是保证PyGILState_Ensure, PyGILState_Release配对使用，而且这个类是可以嵌套使用的。</p>
<p>#include &lt;python.h&gt;</p>
<p>class PyThreadStateLock<br>{<br>public:<br>&nbsp;&nbsp;&nbsp; PyThreadStateLock(void)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state = PyGILState_Ensure( );<br>&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; ~PyThreadStateLock(void)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PyGILState_Release( state );<br>&nbsp;&nbsp;&nbsp; }<br>private:<br>&nbsp;&nbsp;&nbsp; PyGILState_STATE state;<br>};</p>
<p><br>二、在主线程中，这样处理</p>
<p>&nbsp;&nbsp;&nbsp; // 初始化<br>&nbsp;&nbsp;&nbsp; Py_Initialize();<br>&nbsp;&nbsp;&nbsp; // 初始化线程支持<br>&nbsp;&nbsp;&nbsp; PyEval_InitThreads();<br>&nbsp;&nbsp;&nbsp; // 启动子线程前执行，为了释放PyEval_InitThreads获得的全局锁，否则子线程可能无法获取到全局锁。<br>&nbsp;&nbsp;&nbsp; PyEval_ReleaseThread(PyThreadState_Get());<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // 其他的处理，如启动子线程等<br>&nbsp;&nbsp;&nbsp; ......<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // 保证子线程调用都结束后<br>&nbsp;&nbsp;&nbsp; PyGILState_Ensure();<br>&nbsp;&nbsp;&nbsp; Py_Finalize();<br>&nbsp;&nbsp;&nbsp; // 之后不能再调用任何python的API</p>
<p>三、在主线程，或者子线程中，调用python本身函数的都采用如下处理</p>
<p>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class PyThreadStateLock PyThreadLock;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 调用python的API函数处理<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......<br>&nbsp;&nbsp;&nbsp; }</p>
<p>呵呵，看这样是否非常简单了。</p>
<p><br>另外还有两个和全局锁有关的宏，Py_BEGIN_ALLOW_THREADS 和 Py_END_ALLOW_THREADS。这两个宏是为了在较长时间的C函数调用前，临时释放全局锁，完成后重新获取全局锁，以避免阻塞其他python的线程继续运行。这两个宏可以这样调用</p>
<p>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class PyThreadStateLock PyThreadLock;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 调用python的API函数处理<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Py_BEGIN_ALLOW_THREADS<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 调用需要长时间的C函数<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Py_END_ALLOW_THREADS</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 调用python的API函数处理<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......<br>&nbsp;&nbsp;&nbsp; }<br><br><strong>4. 可能的错误及解决</strong> <br>a. 在vs 200x 下 debug 模式出现链接问题 <br>extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_Dealloc referenced in function _PySwigObject_format<br>extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_NegativeRefcount referenced in function _PySwigObject_format<br>extmodule.obj : error LNK2001: unresolved external symbol __imp___Py_RefTotal<br>extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugFree referenced in function _PySwigObject_dealloc<br>extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugMalloc referenced in function _PySwigObject_New<br>extmodule.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs referenced in function _init_extmodule<br><br>主要是因为 Py_DEBUG/Py_TRACE_REFS 引起, 修改 Python\include 下的 pyconfig.h, object.h 两个文件就行了 ... 详见 <a href="http://www.nabble.com/link-error-in-debug-mode-td3126668.html">http://www.nabble.com/link-error-in-debug-mode-td3126668.html</a>&nbsp;<br></p>
<img src ="http://www.cppblog.com/bigsml/aggbug/58859.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bigsml/" target="_blank">泡泡牛</a> 2008-08-14 17:55 <a href="http://www.cppblog.com/bigsml/archive/2008/08/14/58859.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用 python 写 COM </title><link>http://www.cppblog.com/bigsml/archive/2008/08/14/58851.html</link><dc:creator>泡泡牛</dc:creator><author>泡泡牛</author><pubDate>Thu, 14 Aug 2008 09:02:00 GMT</pubDate><guid>http://www.cppblog.com/bigsml/archive/2008/08/14/58851.html</guid><wfw:comment>http://www.cppblog.com/bigsml/comments/58851.html</wfw:comment><comments>http://www.cppblog.com/bigsml/archive/2008/08/14/58851.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bigsml/comments/commentRss/58851.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bigsml/services/trackbacks/58851.html</trackback:ping><description><![CDATA[Python 支持Com调用(client com)&nbsp;以及撰写COM 组件(server com). <br>1. com 调用示例(使用Windows Media Player 播放音乐) <br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;win32com.client&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;Dispatch<br>mp&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;Dispatch(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">WMPlayer.OCX</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>tune&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;mp.newMedia(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">C:/WINDOWS/system32/oobe/images/title.wma</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>mp.currentPlaylist.appendItem(tune)<br>mp.controls.play()</span></div>
<br>2. com server 的编写<br>主要可以参考 &lt;&lt;<a href="http://oreilly.com/catalog/pythonwin32/chapter/ch12.html">Python Programming on Win32 之 Chapter 12 Advanced Python and COM</a>&nbsp;<a href="http://oreilly.com/catalog/pythonwin32/chapter/ch12.html">http://oreilly.com/catalog/pythonwin32/chapter/ch12.html</a>&nbsp;&gt;&gt;<br>示例(分割字符串) <br><strong>- 代码</strong><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;PythonUtilities:<br>&nbsp;&nbsp;&nbsp;&nbsp;_public_methods_&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;[&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">SplitString</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">&nbsp;]<br>&nbsp;&nbsp;&nbsp;&nbsp;_reg_progid_&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">PythonDemos.Utilities</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;NEVER&nbsp;copy&nbsp;the&nbsp;following&nbsp;ID&nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;Use&nbsp;"print&nbsp;pythoncom.CreateGuid()"&nbsp;to&nbsp;make&nbsp;a&nbsp;new&nbsp;one.</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;_reg_clsid_&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">{41E24E95-D45A-11D2-852C-204C4F4F5020}</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000">&nbsp;SplitString(self,&nbsp;val,&nbsp;item</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;string<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;item&nbsp;</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">&nbsp;None:&nbsp;item&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;str(item)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;string.split(str(val),&nbsp;item)<br>&nbsp;<br></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;Add&nbsp;code&nbsp;so&nbsp;that&nbsp;when&nbsp;this&nbsp;script&nbsp;is&nbsp;run&nbsp;by</span><span style="COLOR: #008000"><br>#</span><span style="COLOR: #008000">&nbsp;Python.exe,&nbsp;it&nbsp;self-registers.</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">__name__</span><span style="COLOR: #000000">==</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__main__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Registering&nbsp;COM&nbsp;server<img src="http://www.cppblog.com/Images/dot.gif"></span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;win32com.server.register<br>&nbsp;&nbsp;&nbsp;&nbsp;win32com.server.register.UseCommandLine(PythonUtilities)<br></span></div>
<br><strong>- 注册/注销Com</strong> <br>
<table border=1>
    <tbody>
        <tr>
            <th>
            <p class=CellHeading>Command-Line Option</p>
            </th>
            <th>
            <p class=CellHeading>Description</p>
            </th>
        </tr>
        <tr>
            <td>
            <p class=CellBody>&nbsp;</p>
            </td>
            <td>
            <p class=CellBody>The default is to register the COM objects.</p>
            </td>
        </tr>
        <tr>
            <td>
            <p class=CellBody><code class=Literal>--unregister</code></p>
            </td>
            <td>
            <p class=CellBody>Unregisters the objects. This removes all references to the objects from the Windows registry.</p>
            </td>
        </tr>
        <tr>
            <td>
            <p class=CellBody><code class=Literal>--debug</code></p>
            </td>
            <td>
            <p class=CellBody>Registers the COM servers in debug mode. We discuss debugging COM servers later in this chapter.</p>
            </td>
        </tr>
        <tr>
            <td>
            <p class=CellBody><code class=Literal>--quiet</code></p>
            </td>
            <td>
            <p class=CellBody>Register (or unregister) the object quietly (i.e., don't report success).</p>
            </td>
        </tr>
    </tbody>
</table>
<br><strong>- 使用COM</strong> <br>可以在python 命令行下运行 <br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;win32com.client<br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;s&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;win32com.client.Dispatch(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">PythonDemos.Utilities</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;s.SplitString(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">a,b,c</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">,</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>((u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">a</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">a,b,c</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">),)<br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span></div>
<br>3. python server com 原理 <br>其实在注册表中查找到python com 的实现内幕 <br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">Windows&nbsp;Registry&nbsp;Editor&nbsp;Version&nbsp;</span><span style="COLOR: #000000">5.00</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>@</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">PythonDemos.Utilities</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\Debugging</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>@</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\Implemented&nbsp;Categories</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\Implemented&nbsp;Categories\{B3EF80D0-68E2-11D0-A689-00C04FD658FF}</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\InprocServer32</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>@</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pythoncom25.dll</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ThreadingModel</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">both</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\LocalServer32</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>@</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">D:\\usr\\Python\\pythonw.exe&nbsp;\</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">D:\\usr\\Python\\lib\\site-packages\\win32com\\server\\localserver.py\</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;{41E24E95-D45A-11D2-852C-204C4F4F5020}</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\ProgID</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>@</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">PythonDemos.Utilities</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\PythonCOM</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>@</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">PythonDemos.PythonUtilities</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">[</span><span style="COLOR: #800000">HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\PythonCOMPath</span><span style="FONT-WEIGHT: bold; COLOR: #800000">]</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>@</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">D:\\</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
inproc server 是通过pythoncom25.dll 实现<br>local server 通过localserver.py 实现<br>com 对应的python 源文件信息在 PythonCOMPath &amp; PythonCOM<br><br>4. 使用问题 <br>用PHP 或者 c 调用com 的时候<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$com</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;COM(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">PythonDemos.Utilities</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #800080">$rs</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$com</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">SplitString(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">a&nbsp;b&nbsp;c</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">foreach</span><span style="COLOR: #000000">(</span><span style="COLOR: #800080">$rs</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">as</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$r</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800080">$r</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">?&gt;</span></div>
会碰到下面的一些错误. <br><strong>pythoncom error: PythonCOM Server - The 'win32com.server.policy' module could not be loaded. <br>&lt;type 'exceptions.ImportError'&gt;: No module named server.policy pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005) <br></strong><br><br>可以通过2种方式解决:<br>a. 设置环境 PYTHONHOME = D:\usr\Python <br>另外在c ++ 使用python 的时候, 如果import module 出现错误<strong>&nbsp;'import site' failed; use -v for traceback</strong> 的话, 也可以通过设置这个变量解决. <br><br>b. 为com 生产exe, dll 可执行文件, setup.py 代码如下 : <br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;distutils.core&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;setup&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;py2exe&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;sys&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;shutil&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;Remove&nbsp;the&nbsp;build&nbsp;tree<img src="http://www.cppblog.com/Images/dot.gif">&nbsp;ALWAYS&nbsp;do&nbsp;that!&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">shutil.rmtree(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">build</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;ignore_errors</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">True)&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;List&nbsp;of&nbsp;modules&nbsp;to&nbsp;exclude&nbsp;from&nbsp;the&nbsp;executable&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">excludes&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;[</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">pywin</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">pywin.debugger</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">pywin.debugger.dbgcon</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">pywin.dialogs</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">pywin.dialogs.list</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">]&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;List&nbsp;of&nbsp;modules&nbsp;to&nbsp;include&nbsp;in&nbsp;the&nbsp;executable&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">includes&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;[</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">win32com.server</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">]&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;ModuleFinder&nbsp;can't&nbsp;handle&nbsp;runtime&nbsp;changes&nbsp;to&nbsp;__path__,&nbsp;but&nbsp;win32com&nbsp;uses&nbsp;them&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000">:&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;if&nbsp;this&nbsp;doesn't&nbsp;work,&nbsp;try&nbsp;import&nbsp;modulefinder&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;py2exe.mf&nbsp;as&nbsp;modulefinder&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;win32com&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;p&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;win32com.</span><span style="COLOR: #800080">__path__</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">:]:&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modulefinder.AddPackagePath(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">win32com</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;p)&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;extra&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;[</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">win32com.shell</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">win32com.server</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">]:&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">,"win32com.mapi"&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800080">__import__</span><span style="COLOR: #000000">(extra)&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;sys.modules[extra]&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;p&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;m.</span><span style="COLOR: #800080">__path__</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">:]:&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modulefinder.AddPackagePath(extra,&nbsp;p)&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">except</span><span style="COLOR: #000000">&nbsp;ImportError:&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;no&nbsp;build&nbsp;path&nbsp;setup,&nbsp;no&nbsp;worries.&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">pass</span><span style="COLOR: #000000">&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;Set&nbsp;up&nbsp;py2exe&nbsp;with&nbsp;all&nbsp;the&nbsp;options&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">setup(&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;options&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;{</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">py2exe</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">:&nbsp;{</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">compressed</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">:&nbsp;</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">optimize</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">:&nbsp;</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">"bundle_files":&nbsp;1,&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">dist_dir</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">:&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">COMDist</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">excludes</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">:&nbsp;excludes,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">includes</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">:&nbsp;includes}},&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;The&nbsp;lib&nbsp;directory&nbsp;contains&nbsp;everything&nbsp;except&nbsp;the&nbsp;executables&nbsp;and&nbsp;the&nbsp;python&nbsp;dll.&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;Can&nbsp;include&nbsp;a&nbsp;subdirectory&nbsp;name.&nbsp;</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;zipfile&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;None,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;com_server&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;[</span><span style="COLOR: #800000">'<span style="COLOR: #800000">PythonDemos</span></span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">], # 文件名!!<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<br><br>ref: <br><a href="http://oreilly.com/catalog/pythonwin32/chapter/ch12.html">http://oreilly.com/catalog/pythonwin32/chapter/ch12.html</a>&nbsp;<br><a href="http://blog.donews.com/limodou/archive/2005/09/02/537571.aspx">http://blog.donews.com/limodou/archive/2005/09/02/537571.aspx</a>&nbsp;<br>
<img src ="http://www.cppblog.com/bigsml/aggbug/58851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bigsml/" target="_blank">泡泡牛</a> 2008-08-14 17:02 <a href="http://www.cppblog.com/bigsml/archive/2008/08/14/58851.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>