I want to send datas to the MUTEX owner.
But the first app receives nothing or %*$/!
I wonder how to send string buffer correctly.
Code: Select all
Global WM_Datas_From_PB_App.l
Global MUTEX.l
WM_Datas_From_PB_App = RegisterWindowMessage_("WM_Datas_From_PB_App")
; ///////////////////////////////////////////////////////////////
;-Callback wait datas from the second app
; ////////////////////////////////////////////////////////////////
Procedure WinCallback(Win.l, Message.l, wParam.l, lParam.l)
Result = #PB_ProcessPureBasicEvents
If message = WM_Datas_From_PB_App
lg=wParam
msg$=Space(lg+1)
msg$=PeekS(lParam)
MessageRequester("First App receives datas :",msg$,#PB_MessageRequester_Ok )
EndIf
ProcedureReturn Result
EndProcedure
; ///////////////////////////////////////////////////////////////
;--The second app is destroyed & send datas to the first one
; ////////////////////////////////////////////////////////////////
MUTEX = CreateMutex_(0, 1, "MUTEX_PB_Unique_App")
If (GetLastError_() = #ERROR_ALREADY_EXISTS)
msg$="Second App : parameter="+ProgramParameter()
lg=Len(msg$)
SendMessage_(#HWND_BROADCAST, WM_Datas_From_PB_App, lg, @msg$)
Delay(100)
End
EndIf
; /////////////////////////////////////////
;--The first app survive & Wait datas
; /////////////////////////////////////////
OpenWindow(0,100,100,200,100,#PB_Window_SystemMenu,"First App")
SetWindowCallback(@WinCallback())
Repeat
Until WaitWindowEvent()=#PB_EventCloseWindow
; ////////////////////////
; Release Mutex
; ////////////////////////
ReleaseMutex_(MUTEX)
CloseHandle_(MUTEX)
End 