提交 46f1c29b 编写于 作者: L ljc545w

优化停止服务接口

上级 bdee01c0
......@@ -174,15 +174,16 @@ DWORD StartRobotService() {
}
DWORD StopRobotService() {
DWORD cpid = GetCurrentProcessId();
if (!hProcess)
return 1;
return cpid;
DWORD wxPid = GetWeChatPid();
CheckFriendStatusFinish();
StopReceiveMessage();
RemoveDll(wxPid);
ZeroMemory((wchar_t*)SelfInfoString.c_str(), SelfInfoString.length() * 2 + 2);
CloseHandle(hProcess);
return 0;
return cpid;
}
wstring GetComWorkPath() {
......
......@@ -64,19 +64,16 @@ class WeChatRobot():
self.myinfo = myinfo
return self.myinfo
# 这个可以再更新一下,CStopRobotService返回COM组件的pid
def StopService(self):
import psutil
self.StopReceiveMessage()
status = self.robot.CStopRobotService()
pids = psutil.pids()
for pid in pids:
p = psutil.Process(pid)
process_name = p.name()
if process_name == 'CWeChatRobot.exe':
p.kill()
break
return status
cpid = self.robot.CStopRobotService()
try:
cprocess = psutil.Process(cpid)
cprocess.kill()
except psutil.NoSuchProcess:
pass
return cpid
def GetAddressBook(self):
try:
......@@ -218,17 +215,19 @@ def ReceiveMessageCallBack(robot,message):
sender = wxSender['wxNickName'] if wxSender['wxNickName'] != 'null' else message['sender']
if '@chatroom' in message['sender']:
wxUser = robot.GetWxUserInfo(message['wxid'])
print("来自 {} {}".format(sender,wxUser['wxNickName']))
print("来自 {} {},type {}".format(sender,wxUser['wxNickName',message['type']]))
else:
print("来自 {}".format(sender))
print("来自 {},type {}".format(sender,message['type']))
if message['type'] == 1:
print(message['message'])
elif message['type'] == 3:
print(message['message'])
print(message['filepath'])
elif message['type'] == 49:
print(message['message'])
if not message['filepath']: print(message['filepath'])
else:
print(message['type'],message['message'])
print(message['message'])
def test_SendText():
import os
......@@ -284,4 +283,4 @@ def test_ReceiveMessage():
wx.StopService()
if __name__ == '__main__':
test_ReceiveMessage()
\ No newline at end of file
test_ReceiveMessage()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册