Singles Only!

BlitzMax Modules Forums/Brucey's Modules/Singles Only!

Ever wanted to check if your app was already running? Now you can, with wxSingleInstanceChecker.

You create the object either as a global or perhaps as a field of your wxApp object - so that it stays alive for the duration of your program.

Then, given a unique name, simply check on startup :

Method OnInit:Int()
    Local name:String = "MyApp-" + wxGetUserId() 
    
    m_checker = new wxSingleInstanceChecker.Create(name)
    
    If m_checker.IsAnotherRunning() Then 
        wxLogError(_("Another program instance is already running, aborting.")) 
        Return False
    End If
    ... more initializations ... 
    Return True
End Method




Another wxMax tip for your viewing pleasure..

:o)

Very handy!

Indeed!

Is it possible to send information directly to an already existing instance of the application?
For example: I open a file, then I open another file and it detects the application is already running, so it sends the commandline to the existing instance.

Is it possible to send information directly to an already existing instance of the application?
For example: I open a file, then I open another file and it detects the application is already running, so it sends the commandline to the existing instance.

Should be I think with the wxClient/wxDDEClient & wxServer/wxDDEServer classes, when wxMax get those ported..

Or maybe it's doable already...?

Isn't DDE an ancient *Windows-specific* protocol? I doubt there'd be a wx port of it... I'd be interested in knowing a cross-platform way of achieving what Plash is talking about...

Yes DDE is windows only, but there's a wx class for it, don't ask why tho..
Here's a link to the (not so helpful) wxWidget docs on interprocess communication.

http://docs.wxwidgets.org/stable/wx_ipcoverview.html#ipcoverview

I'm sure something like zeroconf/avahi/bonjour is more suited to this kind of thing...

...but then again...

If anyone really wants it implementing, I can have a look at it.

As Ole's link suggests, wxServer, wxConnection and wxClient, are a cross-platform implementation of it.

And after digging around in my hd/head trying to find out where I've
seen wxConnection stuff used this way, this is where:
http://wxguide.sourceforge.net/editor.html