06-12-2025, 06:41 AM
The following code still does not work. How can I determine the value of mutex_my_exe? Sometimes, the same exe file has different file names, but it is still the same exe instance. How can I solve this problem?
Macro Macro8
Macro Macro8
;at the beginning of exe main function:
SetLastError 0
__Handle m=CreateMutex(0 1 "Macro8") ::
if(!m) mes- "Error"
if(GetLastError=ERROR_ALREADY_EXISTS) ;;another instance of your exe is running
,;possibly execute some code here
,sub.osdTip
,ret ;;exit exe
sub.osdTip
AddTrayIcon "cut.ico" "test_TcpSocket_server[]Ctrl+click to end."
#compile "__TcpSocket"
TcpSocket x.ServerStart(5032 &sub.OnClientConnected)
#sub OnClientConnected
function TcpSocket&client $clientIp param !*reserved
client.Receive(_s 1000)
out F"SERVER: client request: {_s}"
client.Send("response 1")
#sub osdTip
OsdHide "o1"
OnScreenDisplay "TcpSocket_server is Running!" 0 0 0 "" 36 0x33331F 4|8|128 "o1" 0xFFFFFF