473,395 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

creating a single instance application

hi, is there a way to ensure an application will run a single instance (for
example, like word that opens each document in a different word programm) via
mfc features or do i have to code it myself. i did that once by having my
application reserve a socket, but this is very not elegant. i dont want to
use system registry or temp files since an abnormal termination may leave
trash files that may not allow the program to run in following calls
Nov 17 '05 #1
3 1522
"VooDoo" <Vo****@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...
hi, is there a way to ensure an application will run a single instance
(for
example, like word that opens each document in a different word programm)
via
mfc features or do i have to code it myself.


Mostly, you have to do it yourself. One technique is discussed here:

http://support.microsoft.com/kb/q243953/

Just by the way, Word takes advantage of the file associations maintained by
the shell (Explorer).

Files with .doc extensions are associated with winword.exe, so if winword is
not already active, the shell will run it and pass the file name as an
argument.

Winword also supports DDE, and if the shell finds that the application is
already running, it sends a DDE message to the active instance which opens
the document specified in the message in a new window.

Regards,
Will
Nov 17 '05 #2

Mostly, you have to do it yourself. One technique is discussed here:

http://support.microsoft.com/kb/q243953/
tnx, that article is in fact about what i was looking for, tough i have not
seen it yet in detail to see how it does it, so i can not tell if i'll like
it or not
Just by the way, Word takes advantage of the file associations maintained by
the shell (Explorer).

Files with .doc extensions are associated with winword.exe, so if winword is
not already active, the shell will run it and pass the file name as an
argument.

hmm.. i should have said "for example, not like word (...)" which in fact
opens a different instance for each document
Nov 17 '05 #3
"VooDoo" <Vo****@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
hmm.. i should have said "for example, not like word (...)" which in fact
opens a different instance for each document


Hmm, not here. It all depends on how you run the subsequent instances.

I just clicked two different .doc files listed in an Explorer window. Both
documents end up being opened by the same instance of winword.exe (from
Office 2003) as the shell sends a DDE message to open the second instance.

Note that even if you follow the advice in the article, for a short time
there will be multiple instances of your executable running. Each subsequent
instance detects the presence of the first and exits. If you have a document
centric application which might need to open another document, it needs to
follow the shell's example and send a "message" to the first instance to
open it. Of course, you don't have to use DDE.

But the point is that the operating system does not a priori prevent
subsequent instances from being launched in the first place.

Regards,
Will
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: AIMTech | last post by:
We have an IIS+ASP based application server that is capable of providing complex reports to hundreds of users but in some circumstances these reports can take a long time to create. However the...
1
by: Satchidanand Haridas | last post by:
Hi, I have created an application using python/wxPython and py2exe. I have associated a certain file extension with this application so that when I double-click the file, my application is...
8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
18
by: Steve Barnett | last post by:
I want to ensure that there is only ever one instance of my app running on a single PC at any time. I understand that I can achieve this by using a mutex and, if I can't take ownership of the...
3
by: Seth | last post by:
I have been trying to create a mock httpcontext for the purpose of unit testing. I have a class, Customer, that uses cookies. I have set it up to be able to take a httpcontext as a parameter in...
7
by: jsale | last post by:
I have made an ASP.NET web application that connects to SQL Server, reading and writing data using classes. I was recommended to use session objects to store the data per user, because each user...
2
by: vvenk | last post by:
Hello: I am thinking of an object called "user." This object will be instatntiated during a login process. But I want to use this to control the behavior of the application since it will also...
9
by: MrSpock | last post by:
1. Create a new Windows Application project. 2. Open the project properties and check "Make single instance application". 3. Build. 4. Go to the release folder and run the application. 5. Try to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.