Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

starting an application

Status
Not open for further replies.

ceodav

Programmer
Feb 21, 2003
106
IT
hi,
how is possible to translate the function

App.PrevInstance from VB to VC++?

I want my application start only once even if i double click many times on program icon....

thanks
D.
 
Hi,
I don't know this VB function, but I know how to prevent you run your application many times.
Actually I have to say that this piece of code is not mine, but unfortunally I don't remember where a found it.

In your C***App class add a member function, for example

BOOL C***App::IsAlreadyRunning() {

HANDLE hEvent;
hEvent = CreateEvent(NULL, FALSE, TRUE, AfxGetAppaName());

if (GetLastError() == ERROR_ALREADY_EXISTS) {
return TRUE;
}
return FALSE;

}

So, in your C***App InitInstace method you just have to call this function and return FALSE if it is TRUE.


I use it for a "single document" application and it worked fine.

Hope this helps

 
thanks a lot,
i'm using single document too, so i think it will work fine.

bye
Davide
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top