Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to know if application already running?
How to know if application already running? [message #454843] Sun, 01 May 2005 03:04 Go to next message
Eclipse UserFriend
Originally posted by: doug-list.threepenny.net

Is there any way to detect from one SWT application if another SWT
application is already running?

In Windows the usual solution to this was using ::FindWindow() to look
for the window class (or name).

Is there anything like that or any alternative available in SWT?

Doug
Re: How to know if application already running? [message #454888 is a reply to message #454843] Sun, 01 May 2005 18:59 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">You have several options on this one, only one of
them having to do with SWT itself.&nbsp; The Display class has a method
which returns an array of all the Shell(s) open on that Display.&nbsp;
Alternatively, you can use file-locking, even server sockets to
implement the behavior.<br>
<br>
Daniel<br>
</font><br>
Doug Pearson wrote:
<blockquote cite="midd51h7o$5u0$1@news.eclipse.org" type="cite">Is
there any way to detect from one SWT application if another SWT
application is already running?
<br>
<br>
In Windows the usual solution to this was using ::FindWindow() to look
for the window class (or name).
<br>
<br>
Is there anything like that or any alternative available in SWT?
<br>
<br>
Doug
<br>
<br>
</blockquote>
</body>
</html>
Re: How to know if application already running? [message #454889 is a reply to message #454888] Sun, 01 May 2005 20:09 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Daniel Spiewak wrote:

> You have several options on this one, only one of them having to do
> with SWT itself. The Display class has a method which returns an
> array of all the Shell(s) open on that Display. Alternatively, you
> can use file-locking, even server sockets to implement the behavior.

As far as I can see, a new Display class is created with each new SWT
application. So, how should one display
know of the Shells of another application? I dont think (and checked)
that its working.

sockets seem to be the best (and most common) way to achieve this.

Ben

>
> Daniel
>
> Doug Pearson wrote:
>
>> Is there any way to detect from one SWT application if another SWT
>> application is already running?
>>
>> In Windows the usual solution to this was using ::FindWindow() to
>> look for the window class (or name).
>>
>> Is there anything like that or any alternative available in SWT?
>>
>> Doug
>>
Re: How to know if application already running? [message #454890 is a reply to message #454889] Sun, 01 May 2005 20:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: doug-list.threepenny.net

I'd thought about using files, but hadn't considered a socket solution.
That sounds good and will work fine on any platform. Thanks,

Doug

Benjamin Pasero wrote:

> Daniel Spiewak wrote:
>
>
>>You have several options on this one, only one of them having to do
>>with SWT itself. The Display class has a method which returns an
>>array of all the Shell(s) open on that Display. Alternatively, you
>>can use file-locking, even server sockets to implement the behavior.
>
>
> As far as I can see, a new Display class is created with each new SWT
> application. So, how should one display
> know of the Shells of another application? I dont think (and checked)
> that its working.
>
> sockets seem to be the best (and most common) way to achieve this.
>
> Ben
>
>
>>Daniel
>>
>>Doug Pearson wrote:
>>
>>
>>>Is there any way to detect from one SWT application if another SWT
>>>application is already running?
>>>
>>>In Windows the usual solution to this was using ::FindWindow() to
>>>look for the window class (or name).
>>>
>>>Is there anything like that or any alternative available in SWT?
>>>
>>>Doug
>>>
Re: How to know if application already running? [message #454893 is a reply to message #454890] Mon, 02 May 2005 07:50 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Doug Pearson wrote:

> I'd thought about using files, but hadn't considered a socket
> solution. That sounds good and will work fine on any platform.
> Thanks,

Maybe if you could share your solution with Sockets here? I was thinking
of implementing a Socket-way
to get out if my application is already running. But I wonder what port
to chose to run the Socket through?

Ben

>
> Doug
>
> Benjamin Pasero wrote:
>
>> Daniel Spiewak wrote:
>>
>>
>>> You have several options on this one, only one of them having to do
>>> with SWT itself. The Display class has a method which returns an
>>> array of all the Shell(s) open on that Display. Alternatively, you
>>> can use file-locking, even server sockets to implement the behavior.
>>
>>
>>
>> As far as I can see, a new Display class is created with each new SWT
>> application. So, how should one display
>> know of the Shells of another application? I dont think (and checked)
>> that its working.
>>
>> sockets seem to be the best (and most common) way to achieve this.
>>
>> Ben
>>
>>
>>> Daniel
>>>
>>> Doug Pearson wrote:
>>>
>>>
>>>> Is there any way to detect from one SWT application if another SWT
>>>> application is already running?
>>>>
>>>> In Windows the usual solution to this was using ::FindWindow() to
>>>> look for the window class (or name).
>>>>
>>>> Is there anything like that or any alternative available in SWT?
>>>>
>>>> Doug
>>>>
>
Re: How to know if application already running? [message #454896 is a reply to message #454843] Mon, 02 May 2005 10:24 Go to previous messageGo to next message
Tiberiu Caprita is currently offline Tiberiu CapritaFriend
Messages: 68
Registered: July 2009
Member
FindWindow is exported by SWT in OS class.

Doug Pearson wrote:
> In Windows the usual solution to this was using ::FindWindow() to look
> for the window class (or name).

> Is there anything like that or any alternative available in SWT?
Re: How to know if application already running? [message #454906 is a reply to message #454893] Mon, 02 May 2005 14:39 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">I would run it on port 25, the smtp mail server
port.&nbsp; This port is fairly commonly allowed, but few systems actually
run a mail server.<br>
<br>
As to the Display class, it is a static method which to the best of my
knowledge, queries the system for all open Shell(s), even the native
ones, and returns them in an array.&nbsp; I use this method to show error
dialogs when my application unexpected quits.&nbsp; But, all in all, I'd use
sockets first.&nbsp; More reliable, more flexible, less confusing, and all
around a more elegant hack.<br>
<br>
Daniel<br>
</font><br>
Benjamin Pasero wrote:
<blockquote cite="midd54j5h$nur$1@news.eclipse.org" type="cite">
<pre wrap="">Doug Pearson wrote:

</pre>
<blockquote type="cite">
<pre wrap="">I'd thought about using files, but hadn't considered a socket
solution. That sounds good and will work fine on any platform.
Thanks,
</pre>
</blockquote>
<pre wrap=""><!---->
Maybe if you could share your solution with Sockets here? I was thinking
of implementing a Socket-way
to get out if my application is already running. But I wonder what port
to chose to run the Socket through?

Ben

</pre>
<blockquote type="cite">
<pre wrap="">Doug

Benjamin Pasero wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Daniel Spiewak wrote:


</pre>
<blockquote type="cite">
<pre wrap="">You have several options on this one, only one of them having to do
with SWT itself. The Display class has a method which returns an
array of all the Shell(s) open on that Display. Alternatively, you
can use file-locking, even server sockets to implement the behavior.
</pre>
</blockquote>
<pre wrap="">

As far as I can see, a new Display class is created with each new SWT
application. So, how should one display
know of the Shells of another application? I dont think (and checked)
that its working.

sockets seem to be the best (and most common) way to achieve this.

Ben


</pre>
<blockquote type="cite">
<pre wrap="">Daniel

Doug Pearson wrote:


</pre>
<blockquote type="cite">
<pre wrap="">Is there any way to detect from one SWT application if another SWT
application is already running?

In Windows the usual solution to this was using ::FindWindow() to
look for the window class (or name).

Is there anything like that or any alternative available in SWT?

Doug

</pre>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>
Re: How to know if application already running? [message #454925 is a reply to message #454906] Mon, 02 May 2005 21:11 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Daniel Spiewak wrote:

> I would run it on port 25, the smtp mail server port. This port is
> fairly commonly allowed, but few systems actually run a mail server.
>
> As to the Display class, it is a static method which to the best of my
> knowledge, queries the system for all open Shell(s), even the native
> ones, and returns them in an array. I use this method to show error
> dialogs when my application unexpected quits.

I am not seeing any public static method in Display that returns an
array of Shells. Are you using an older
version of SWT, maybe from 3.0?

> But, all in all, I'd use sockets first. More reliable, more flexible,
> less confusing, and all around a more elegant hack.

I think a Display-Method would be most elegant. The disadvantage of
Sockets is always that the user most likely
will be prompted by his firewall to allow the application to communicate
on the given port. Having port 25, most
users will rightfully ask, why the application requires the SMTP Port to
be opened.

Ben

>
> Daniel
>
> Benjamin Pasero wrote:
>
>>Doug Pearson wrote:
>>
>>
>>
>>>I'd thought about using files, but hadn't considered a socket
>>>solution. That sounds good and will work fine on any platform.
>>>Thanks,
>>>
>>>
>>Maybe if you could share your solution with Sockets here? I was thinking
>>of implementing a Socket-way
>>to get out if my application is already running. But I wonder what port
>>to chose to run the Socket through?
>>
>>Ben
>>
>>
>>
>>>Doug
>>>
>>>Benjamin Pasero wrote:
>>>
>>>
>>>
>>>>Daniel Spiewak wrote:
>>>>
>>>>
>>>>
>>>>
>>>>>You have several options on this one, only one of them having to do
>>>>>with SWT itself. The Display class has a method which returns an
>>>>>array of all the Shell(s) open on that Display. Alternatively, you
>>>>>can use file-locking, even server sockets to implement the behavior.
>>>>>
>>>>>
>>>>As far as I can see, a new Display class is created with each new SWT
>>>>application. So, how should one display
>>>>know of the Shells of another application? I dont think (and checked)
>>>>that its working.
>>>>
>>>>sockets seem to be the best (and most common) way to achieve this.
>>>>
>>>>Ben
>>>>
>>>>
>>>>
>>>>
>>>>>Daniel
>>>>>
>>>>>Doug Pearson wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Is there any way to detect from one SWT application if another SWT
>>>>>>application is already running?
>>>>>>
>>>>>>In Windows the usual solution to this was using ::FindWindow() to
>>>>>>look for the window class (or name).
>>>>>>
>>>>>>Is there anything like that or any alternative available in SWT?
>>>>>>
>>>>>>Doug
>>>>>>
>>>>>>
>>>>>>
Re: How to know if application already running? [message #454931 is a reply to message #454925] Tue, 03 May 2005 01:13 Go to previous message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">Whoops.&nbsp; I went back and rechecked my code.&nbsp; What I
was thinking of was Display#getShells().&nbsp; Ignore what I said about
there being a way to do it with Display.&nbsp; :-)<br>
<br>
As to port 25, you'll have the same problem with just about any port.&nbsp;
I guess 25 is as good as any other.<br>
<br>
Daniel<br>
</font><br>
Benjamin Pasero wrote:
<blockquote cite="midd5623u$q02$1@news.eclipse.org" type="cite">
<pre wrap="">Daniel Spiewak wrote:

</pre>
<blockquote type="cite">
<pre wrap="">I would run it on port 25, the smtp mail server port. This port is
fairly commonly allowed, but few systems actually run a mail server.

As to the Display class, it is a static method which to the best of my
knowledge, queries the system for all open Shell(s), even the native
ones, and returns them in an array. I use this method to show error
dialogs when my application unexpected quits.
</pre>
</blockquote>
<pre wrap=""><!---->
I am not seeing any public static method in Display that returns an
array of Shells. Are you using an older
version of SWT, maybe from 3.0?

</pre>
<blockquote type="cite">
<pre wrap="">But, all in all, I'd use sockets first. More reliable, more flexible,
less confusing, and all around a more elegant hack.
</pre>
</blockquote>
<pre wrap=""><!---->
I think a Display-Method would be most elegant. The disadvantage of
Sockets is always that the user most likely
will be prompted by his firewall to allow the application to communicate
on the given port. Having port 25, most
users will rightfully ask, why the application requires the SMTP Port to
be opened.

Ben

</pre>
<blockquote type="cite">
<pre wrap="">Daniel

Benjamin Pasero wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Doug Pearson wrote:



</pre>
<blockquote type="cite">
<pre wrap="">I'd thought about using files, but hadn't considered a socket
solution. That sounds good and will work fine on any platform.
Thanks,


</pre>
</blockquote>
<pre wrap="">Maybe if you could share your solution with Sockets here? I was thinking
of implementing a Socket-way
to get out if my application is already running. But I wonder what port
to chose to run the Socket through?

Ben



</pre>
<blockquote type="cite">
<pre wrap="">Doug

Benjamin Pasero wrote:



</pre>
<blockquote type="cite">
<pre wrap="">Daniel Spiewak wrote:




</pre>
<blockquote type="cite">
<pre wrap="">You have several options on this one, only one of them having to do
with SWT itself. The Display class has a method which returns an
array of all the Shell(s) open on that Display. Alternatively, you
can use file-locking, even server sockets to implement the behavior.


</pre>
</blockquote>
<pre wrap="">As far as I can see, a new Display class is created with each new SWT
application. So, how should one display
know of the Shells of another application? I dont think (and checked)
that its working.

sockets seem to be the best (and most common) way to achieve this.

Ben




</pre>
<blockquote type="cite">
<pre wrap="">Daniel

Doug Pearson wrote:




</pre>
<blockquote type="cite">
<pre wrap="">Is there any way to detect from one SWT application if another SWT
application is already running?

In Windows the usual solution to this was using ::FindWindow() to
look for the window class (or name).

Is there anything like that or any alternative available in SWT?

Doug



</pre>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>
Previous Topic:IM user list like widget
Next Topic:Table SWT and Selection
Goto Forum:
  


Current Time: Mon Sep 23 15:01:50 GMT 2024

Powered by FUDForum. Page generated in 0.06120 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top