Discussion:
Regarding CreateMutexA and CreateMutexW
(too old to reply)
mshetty
2003-11-15 00:56:12 UTC
Permalink
Hi,

When you have a CreateMutex what is the use of CreateMutexW and
CreateMutexA?? Are they available only for specific platforms?? Where
can I get more information on this??

MSDN only talks of CreateMutexW. It says
"CreateMutexW is supported by the Microsoft Layer for Unicode." on
platforms
Windows Me/98/95.

Couldn't find any mention of CreateMutexA.

Thanks and Regards,
M Shetty
Tim Robinson
2003-11-15 01:25:32 UTC
Permalink
Windows functions that accept strings as parameters (and some that don't)
generally have two versions: ANSI (A) and Unicode (W). Internally they have
names like CreateFileA/CreateFileW, CreateWindowExA/CreateWindowExW and
CreateMutexA/CreateMutexW. The A/W variants are partially hidden by #defines
within the Windows header files which map, say, CreateMutex to CreateMutexA
or CreateMutexW depending on whether you have #define UNICODE. Regardless of
whether UNICODE is defined, you can still call either the A or W function by
adding the A or W explictly. For example, you can call CreateWindowExW from
an ANSI program.

On Windows NT platforms, the A function converts its parameters to Unicode
and calls the W function, which does the work. On Win9x, the A function does
all the work and the W function returns failure (not supported).

The Microsoft Layer for Unicode (MSLU, or Unicows) allows you to use most
Unicode functions (functions whose names end in W) by performing the
opposite mapping to what Windows NT does. It provides its own W functions,
which convert their parameters to ANSI, then call the corresponding A
function.
--
Tim Robinson (MVP, Windows SDK)
http://www.themobius.co.uk/
Post by mshetty
Hi,
When you have a CreateMutex what is the use of CreateMutexW and
CreateMutexA?? Are they available only for specific platforms?? Where
can I get more information on this??
MSDN only talks of CreateMutexW. It says
"CreateMutexW is supported by the Microsoft Layer for Unicode." on
platforms
Windows Me/98/95.
Couldn't find any mention of CreateMutexA.
Thanks and Regards,
M Shetty
r***@pen_fact.com
2003-11-15 16:45:59 UTC
Permalink
On Sat, 15 Nov 2003 01:25:32 -0000, "Tim Robinson"
Post by Tim Robinson
Windows functions that accept strings as parameters (and some that don't)
generally have two versions: ANSI (A) and Unicode (W). Internally they have
names like CreateFileA/CreateFileW, CreateWindowExA/CreateWindowExW and
CreateMutexA/CreateMutexW. The A/W variants are partially hidden by #defines
within the Windows header files which map, say, CreateMutex to CreateMutexA
or CreateMutexW depending on whether you have #define UNICODE. Regardless of
whether UNICODE is defined, you can still call either the A or W function by
adding the A or W explictly. For example, you can call CreateWindowExW from
an ANSI program.
I think this is a very powerful feature of the Win32 API. Definitely
tedious to implement. But _very_ useful for folks (like me) who use
the Win32 API. It lets me use the same source code for Windows CE
(_always_ UNICODE) and Win 95 (for my purposes, _never_ UNICODE).

If browsing is enabled (see Project->Settings C++ and Browse Info
tabs), you can right click on a string to go to the definition of that
string, and see the mechanics directly.

I strongly recommend reading tchar.h. It is _not_ meant for human
consumption, and I needed several attempts. But understanding the
macros it defines will go a long way towards understanding the power
of #ifdef UNICODE.
Post by Tim Robinson
On Windows NT platforms, the A function converts its parameters to Unicode
and calls the W function, which does the work. On Win9x, the A function does
all the work and the W function returns failure (not supported).
The Microsoft Layer for Unicode (MSLU, or Unicows) allows you to use most
Unicode functions (functions whose names end in W) by performing the
opposite mapping to what Windows NT does. It provides its own W functions,
which convert their parameters to ANSI, then call the corresponding A
function.
--
Tim Robinson (MVP, Windows SDK)
http://www.themobius.co.uk/
Post by mshetty
Hi,
When you have a CreateMutex what is the use of CreateMutexW and
CreateMutexA?? Are they available only for specific platforms?? Where
can I get more information on this??
MSDN only talks of CreateMutexW. It says
"CreateMutexW is supported by the Microsoft Layer for Unicode." on
platforms
Windows Me/98/95.
Couldn't find any mention of CreateMutexA.
Thanks and Regards,
M Shetty
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com

Loading...