Hi!
For IPC.Mailslot, if you need, you can look my little example-code (below).
Tested for compatibility with Vista.waitfor.exe ; and tested XP <=>
Vista via LAN
(sorry for my bad english)
@-salutations
--
Michel Claveau
# -*- coding: cp1252 -*-
def mailslotserver(duree=999999, systemname='.', mailslotname="waitfor.exe",
signal="SIGNAL"):
"""Attend (surveille) un mailslot
Exemple :
flag,data=mailslot.mailslotserver( duree=600, systemname=".",
mailslotname="waitfor.exe", signal="SIGNAL" )
"""
import ctypes, win32file
myslot = '\\\\'+systemname+'\\mailslot\\'+mailslotname+'\\'+signal
nbs=ctypes.c_long(duree*1000)
hReceive = ctypes.windll.kernel32.CreateMailslotA(myslot, 0, nbs, 0)
if hReceive == -1:
data="Access error to Mailslot"
return False,data
buffer = win32file.AllocateReadBuffer(400)
try:
rc, data = win32file.ReadFile(hReceive, buffer)
except:
data="out of time"
return False,data
return True,data
def mailslotclient( systemname='.', mailslotname="waitfor.exe",
signal="SIGNAL", data='ABC'):
"""Envoie un message par mailslot
Exemples :
mailslotclient( systemname="*", mailslotname="waitfor.exe",
signal="SIGNAL", data="TESTCLIENT et c'est noël €" )
mailslotclient( systemname="ServeurCPQ", mailslotname="waitfor.exe",
signal="SYNCHRO", data="Terminé" )
"""
import win32file,win32con
#print 23,'\\\\'+systemname+'\\mailslot\\'+mailslotname+'\\'+signal
mailslot =
win32file.CreateFile('\\\\'+systemname+'\\mailslot\\'+mailslotname+'\\'+signal,
win32file.GENERIC_WRITE, 0, None, win32con.CREATE_NEW, 0, None)
#print 24,"mailslot",mailslot
import time
time.sleep(0.1)
win32file.WriteFile(mailslot, data)
mailslot.Close()
if __name__ == '__main__':
import sys
if len(sys.argv)>1:
if sys.argv[1].upper()[:4]=="SERV":
flag,data=mailslotserver(duree=9, systemname=".",
mailslotname="waitfor.exe", signal="SIGNAL")
print "Résultat : ",flag," (",data,") "
else:
mailslotclient(systemname=".", mailslotname="waitfor.exe",
signal="SIGNAL", data="TESTCLIENT")
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32