网站建设凭证,com域名注册情况,何苦做游戏网站,制作网站的app吗项目需要做WINFORM程序与powerpoint交互#xff0c;把winform生成的图片自动拷贝到ppt中。目前使用python做了一个简单的服务解决。由于要求是32位程序#xff0c;所以下面全都是32位的版本。第一步#xff0c;安装python2.7 32位。第二部#xff0c;安装py2exe 32位。第三…项目需要做WINFORM程序与powerpoint交互把winform生成的图片自动拷贝到ppt中。目前使用python做了一个简单的服务解决。由于要求是32位程序所以下面全都是32位的版本。第一步安装python2.7 32位。第二部安装py2exe 32位。第三步安装pywin32 32位。第四步用Eclipse(pydev插件)写代码见附件。主要内容如下// wavy_ppt_service.pyimport SocketServerimport win32com.clientimport sysclass MyTCPHandler(SocketServer.BaseRequestHandler):The RequestHandler class for our server.It is instantiated once per connection to the server, and mustoverride the handle() method to implement communication to theclient.def handle(self):# self.request is the TCP socket connected to the clientself.data self.request.recv(1024).strip()# print {} wrote:.format(self.client_address[0])# print self.data# just send back the same data, but upper-cased# self.request.sendall(self.data.upper())Application win32com.client.Dispatch(PowerPoint.Application)currentSlide Application.ActiveWindow.View.SlidecurrentSlide.Shapes.Paste()HOST, PORT localhost, int(sys.argv[1])#HOST, PORT localhost, 9999# Create the server, binding to localhost on port 9999server SocketServer.TCPServer((HOST, PORT), MyTCPHandler)# Activate the server; this will keep running until you# interrupt the program with Ctrl-Cserver.serve_forever()就是用客户端和服务端的方式做的一个服务服务端接收到数据后会将剪切板的图片拷贝到ppt中。打开cmd调用buildExe32.bat就可以生成dist目录了包含着exe 程序。原文http://2924037.blog.51cto.com/2914037/1692967