Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: BeeJ Newsgroups: microsoft.public.vb.general.discussion,comp.lang.basic.visual.misc Subject: Re: Handling second instance works in IDE but not when compiled Date: Wed, 17 Oct 2012 12:24:52 -0700 Organization: Aioe.org NNTP Server Lines: 38 Message-ID: References: NNTP-Posting-Host: 00Cwq/Rp02Va+sgvmA/Qqg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.02 (Win32) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.basic.visual.misc:1609 On Sat, 13 Oct 2012 18:30:34 -0700, -mhd wrote: > Normally when I detect a running instance of my prog by using a mutex > value, I > just kill the second instance but now I also want to bring the first > instance up > to normal state if its minimized. > > > MutexValue = CreateMutex(ByVal 0&, 1, "MyProgMutex") > If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then > CloseHandle MutexValue > 'Search for Window / Get its Handle > lhwnd = FindWindow(vbNullString, "My Prog Caption") > 'If Another Window Found > If lhwnd <> 0 Then > 'Activate and Show Window > lRtrn = ShowWindow(lhwnd, SW_SHOWRESTORE) > End If > 'this instance exits sub main and dies > Exit Sub > End If > > Works just great in the IDE as the first instance pops up from minimized > state > and the second one dies. > > When compiled the second one dies immediately upon launching as intended > but the > first one doesn't pop up. > > Any ideas? > > -mike -- Using Opera's revolutionary email client: http://www.opera.com/mail/