Reputation: 3503
I'd like to know a way to do the following:
App starts, no forms created. 2nd App instance starts, it detects one instance is already running (this is sorted already)
I want 2nd instance to send the 1st one a message, without using BROADCAST; Id like a way to find a handle to the 1st instance to send it the message directly.
The 1st instance must have a class name to be found with that the 2nd one hasn't yet created, so that it won't send the message to itself.
How would I use FindWindow in this scenario? How do I create a window-less class/object identifiable by FindWindow?
Upvotes: 0
Views: 1378
Reputation: 595467
You can send messages to the TApplication
window if you know the value of its Title
property. The sending instance can temporarily set its own Title
to a different value so as not to confuse FindWindow()
. The receiving instance can use the TApplication.OnMessage
event or TApplication.HookMainWindow()
method to receive the message.
Upvotes: 1
Reputation: 4622
You could use shared memory to pass data. See this article for details
Upvotes: 1
Reputation: 80127
You can not find windowless object by means of FindWindow.
But you can create invisible window with AllocateHWnd function - see TTimer source as example. Use SetWindowText to set title for easy searching
Upvotes: 2