Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9226575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:51:52+00:00 2026-06-18T04:51:52+00:00

I am porting some Win32 code to C#, and have come accross several functions

  • 0

I am porting some Win32 code to C#, and have come accross several functions which have the same names and use the same structures except that they end with A and W

For example:

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("shell32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool Shell_NotifyIconA(uint dwMessage, ref NOTIFYICONDATAA lpData);

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("shell32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool Shell_NotifyIconW(uint dwMessage, ref NOTIFYICONDATAW lpData);

I have seen some implementations in C# which omit the A and W from both the function name, and the associated structure, like so:

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("shell32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool Shell_NotifyIcon(uint dwMessage, ref NOTIFYICONDATA lpData);

What I want to know is:

  1. What do A and W denote?

  2. In C#, should I implement the functions as shown above, using both A and W, or is it better practice to omit A and W in favour of having a single implementation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:51:53+00:00Added an answer on June 18, 2026 at 4:51 am

    The “A” suffix (which stands for ANSI) means that the function works with input multi-byte strings (probably some members of NOTIFYICONDATA are strings), while “W” (which stands for “Wide”) means the function works with input Unicode strings.

    In Windows, it is better to work with Unicode strings whenever possible, because that’s what the OS internally uses. Thus, if your project invokes a Windows API by passing a multi-byte string, a conversion to Unicode will eventually happen internally (and possibly a second conversion back to multi-byte if the OS also returns you a string), slowing things down.

    Usually, when two versions of a certain data structure of function X exist for multi-byte and Unicode characters, they are given the names (respectively) XA and XW, and a conditional alias X is defined to resolve into one or the other based on your project’s settings (an #ifdef does the switch).

    I do not know enough about C# to answer the second part of the question.

    EDIT:

    As pointed out by David Heffernan, the p/invoke marshaller will resolve the name to the one that matches the CharSet used in the DllImport attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm porting some crufty C++ Windows-code to Linux, which uses functions called open and
I'm porting some C++ code to C#. Does C# have an equivalent to std::nth_element()
I am porting some C# code to C++ and have the following problem, see
I'm porting some code from Java to C, and so far things have gone
I am porting some Java code to Python and we would like to use
I am doing some cross-platform work, porting code from Linux to Win32, but when
I'm porting some code from one framework library to another, which requires me to
I'm busy porting some MySQL specific code to Postgresql in order to use it
I'm porting some Windows code to the Mac. I've come across some code using
I am porting some code from windows to Linux (Ubuntu 9.10). I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.