Article View: borland.public.cppbuilder.nativeapi
Article #6580Re: Avoiding multiple programinstances and restore the firstone
From: Hans Galema
Date: Fri, 22 Apr 2005 17:33
Date: Fri, 22 Apr 2005 17:33
36 lines
1993 bytes
1993 bytes
Hans Galema wrote:
> What I meant was that you can omit the mutex: (untested)
Now tested. This works ok and has less code and is much faster
as my original post.
> bool StartNewInstance( AnsiString NAME, AnsiString MUTEX )
> {
> AnsiString OldTitle = Application->Title;
>
> Application->Title = "Something different";
> HWND FirstWnd;
> FirstWnd = ::FindWindow( "TApplication", NAME.c_str() );
> // TApplication ???
Yes: TApplication. You could provide a NULL too.
>
> if ( FirstWnd )
> {
> if ( ::IsIconic( FirstWnd ) ) ::ShowWindow( FirstWnd,
> SW_SHOWDEFAULT );
> ::SetForegroundWindow( FirstWnd );
>
> Application->Title = OldTitle;
>
> return ( false );
> }
>
> Application->Title = OldTitle;
>
> return ( true );
> }
Hans.
Technical Details
Message-ID:
<42693603$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4268dde6$1@newsgroups.borland.com> <4268ff3a$1@newsgroups.borland.com> <42690325$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fd5c6cb9a40ec609 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 22 Apr 2005 19:33:29 +0200 From: Hans Galema <notused@notused.nl> User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Avoiding multiple programinstances and restore the firstone References: <4268dde6$1@newsgroups.borland.com> <4268ff3a$1@newsgroups.borland.com> <42690325$1@newsgroups.borland.com> In-Reply-To: <42690325$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 129.125.201.248 Message-ID: <42693603$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1114191363 129.125.201.248 (22 Apr 2005 10:36:03 -0700) Lines: 36 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail