当前位置: 首页 > article >正文

python 注册一个windows 服务

#
```
python2.7 环境
pip freeze > requirements.txt

PyInstaller==3.0
pywin32==228

pip install -r requirements.txt
```

```angular2html
# coding=utf-8
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
import time

class DemoService(win32serviceutil.ServiceFramework):
    _svc_name_ = "PythonDemoService"
    _svc_display_name_ = "Python Demo Service"
    _svc_description_ = "This is a Python Windows Service Demo"

    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
        socket.setdefaulttimeout(60)
        self.is_running = True

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.hWaitStop)
        self.is_running = False

    def SvcDoR

http://www.kler.cn/a/564420.html

相关文章:

  • FANUC机器人ROBOGUIDE软件中如何添加自定义工具?
  • 中央一号文件里的三维革命:数字孪生如何重构智慧乡村生态?
  • DeepSeek 助力 Vue3 开发:打造丝滑的列表(List)
  • 考研出分24小时,人类精神状态图鉴
  • 5分钟学习-什么事前端HTML文件
  • C#实现本地Deepseek模型及其他模型的对话
  • domain 网络安全 网络安全域
  • staruml绘制时序图和用例图
  • win32汇编环境,对话框中状态栏的应用示例
  • Django模板系统深入
  • 当AI搜索撕开传统搜索的裂缝,警惕AI搜索的“信息茧房”
  • V-HOP:结合视觉和触觉多模态融合数据集,助力机器人实现鲁棒的6D物体姿态跟踪
  • MySQL进阶04-MVCC实现原理
  • 《以太坊账户模型与数据结构:探秘区块链世界的架构密码》
  • Unity:背景图像的旋转和按钮的缩放动画
  • 2025最新智能优化算法:人工旅鼠算法(Artificial Lemming Algorithm, ALA)求解23个经典函数测试集,MATLAB
  • 神经网络中的Adam
  • 西电大数据安全与隐私Lab4(数据安全检索)
  • x64汇编下过程参数解析
  • 卡 bug 了?