🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10016

Re: Run Once

#10016
From: Remy Lebeau (TeamB)
Date: Mon, 31 May 2004 00:20
31 lines
2354 bytes
"JD" <nospam@nospam.com> wrote in message
news:40b9cff4$1@newsgroups.borland.com...

>               // If the Main form is an MDIParent, doesn't that mean
>               // that FindWindow can fail here because the user can
>               // maximize a Child form, changing the MDIParent's caption?

Yes, it can.  One thing you can do is give your MainForm a unique class
name, and then specify that class name when calling FindWindow(), ie:

    HWND hWnd = ::FindWindow( "MyUniqueMainFormClassName", NULL );

> BCB6 - XP

Note that XP deals with globals differently than earlier versions of Windows
due to its "Fast User Switching" feature.  Multiple users can run your
program simultaneously because each user will have its own set of global
resources, so each user could have their own mutex instances all named
"MySpecialMutexName" and the system would treat them differently.  If that
is ok with you, then your current code will work fine.  But if you are
trying to write a program that needs total exclusiveness throughout the
system, such as if its dealing with hardware, then you would have to append
"Global\\" to your mutex name in order to obtain a true global mutex.  Note,
however, that if you intend to run your program on non-XP machines, then you
will have to dynamically name your mutex based on the actual OS.  "Global\\"
will be ignored by Win2K, but it will fail CreateMutex() altogether on any
OS prior to that since "\\" is an illegal character.


Gambit
Technical Details
Message-ID: <40ba7b52$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <40b9cff4$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,55fa8aeaf57fcad1
X-Google-Attributes: gid10cc67,public
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40b9cff4$1@newsgroups.borland.com>
Subject: Re: Run Once
Date: Sun, 30 May 2004 17:20:20 -0700
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 67.22.135.163
Message-ID: <40ba7b52$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1085963090 67.22.135.163 (30 May 2004 17:24:50 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail