Preventing multiple instances

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

izaram
Posts: 5
Joined: 2003-03-19 09:02

Preventing multiple instances

Post by izaram » 2003-03-19 09:38

Hello. I'm trying to implement the DC++ URL Handler code kindly posted by sarf here and I've gotten it to work with the current version (0.24). Unfortunately, when I click on dchub link, a new instance of the program is opened. This is different from older versions, since I have compiled v0.181 and it behaves the way I would expect it (the link is sent to the current instance of the program running).

I was hoping someone a litle more familar with the code could point me in the direction of the change in the source that makes newer versions allow multiple instances to run.

Thank you very much in advance.
--

Izaram

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-08 02:46
Location: .pa.us

Re: Preventing multiple instances

Post by GargoyleMT » 2003-03-19 12:45

If you compiled the debugging configuration, the multiple instance code has been conditionally excluded from that for a while. Look for a #ifndef _DEBUG in the windows\main.cpp file.

izaram
Posts: 5
Joined: 2003-03-19 09:02

Post by izaram » 2003-03-19 22:04

Very cool. Thanks you very much GargoyleMT! :)

Now to figure out how to stop it from crashing when I queue the same item twice... will work on that later tonite.

Thanks again.

edit: Fixed the crashes. Just needed to add a try...catch block around the download code.
--

Izaram

smitty
Posts: 53
Joined: 2003-03-01 19:45

Post by smitty » 2003-05-21 20:06

I deleted this from code and can run multiple DC++ with new version

Code: Select all

if(dcapp.IsAnotherInstanceRunning()) {
HWND hOther = NULL;
EnumWindows(searchOtherInstance, (LPARAM)&hOther);

if( hOther != NULL ) {
 // pop up
 ::SetForegroundWindow(hOther);

 if( IsIconic(hOther)) {
  // restore
  ::ShowWindow(hOther, SW_RESTORE);
 }
 sendCmdLine(hOther, lpstrCmdLine);
}

return FALSE;
}
Knowledge is Earned BUT Wisdom is Free

smitty
Posts: 53
Joined: 2003-03-01 19:45

Post by smitty » 2003-05-21 20:07

It's in main.cpp
Knowledge is Earned BUT Wisdom is Free

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-08 02:46
Location: .pa.us

Post by GargoyleMT » 2003-05-22 04:08

Also in main.cpp, in the function _tWinMain(), there's this line:

Code: Select all

SingleInstance dcapp("{DCPLUSPLUS-AEE8350A-B49A-4753-AB4B-E55479A48351}");


Why a multi-line fix when one will do? :)

Who is online

Users browsing this forum: Google [Bot] and 0 guests