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 6534477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:15:20+00:00 2026-05-25T10:15:20+00:00

To execute a command from the Win shell I needed ShellExecuteA(NULL, open, http://stackoverflow.com, NULL,

  • 0

To execute a command from the Win shell I needed

ShellExecuteA(NULL, "open", "http://stackoverflow.com", NULL, NULL, SW_SHOWNORMAL);

and now I am working through Forgers Win32 Tutorial I am finding the A suffix necessary to prevent printing garbage to the screen. I know this is something to do with the format of characters my OS defaults to. If I could ‘normalize’ my OS that might be the best solution because I am getting NULL back from RegisterClassExA no matter how many *A functions I use in the second example (reproduced below with llloottttssss of *A suffixes added by me)

#include <windows.h>
const wchar_t g_szClassName[] = L"myWindowClass";
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{/*...*/
    return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    HWND hwnd;
    MSG Msg;
    //Step 1: Registering the Window Class
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, L"Window Registration Failed!", L"Error!",
        MB_ICONEXCLAMATION | MB_OK);
    return 0;
    }
    // Step 2: Creating the Window...
    return Msg.wParam;
}

I’ve revisited the code above to make it like Forgers (removed *A’s) and used L"" string initializers instead, but now I get an error assigning const char g_szClassName[] = L"myWindowClass";

error C2053: ‘g_szClassName’ : wide string mismatch

Replacing char with wchar generates compiler error messages indicating wchar is not a recognized type.

_EDIT_

I gather the L"" string specifier is the preferred solution and the one I’d like to pursue, sorry if my question seems to beat around the bush, I’m open to suggestions.

Just updated that code to what I am now using and cut out the stuff I can’t reach.

_EDIT_

The error code is 87, invalid parameter, so I guess assigning the wchar_t parameter ( wc.lpszClassName = g_szClassName;) is incorrect after all… :@(

_EDIT_

Guessed wrong?! const LPCTSTR g_szClassName = L"myWindowClass"; didn’t fix (or break) a thing.

  • 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-05-25T10:15:21+00:00Added an answer on May 25, 2026 at 10:15 am

    If you want unicode string, the keyword is wchar_t

    const wchar_t g_szClassName[] = L"myWindowClass";
    

    Edit:

    Also, make sure you zero-initialize the rest of members of structure WNDCLASSEX that you haven’t set, i.e.

    WNDCLASSEX wc = {};
    

    OR

    ZeroMemory(&wc, sizeof(wc));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to execute a shell command from Ruby script but I have to
I would like to execute a command via Django's manage.py shell function solely from
I am using System() command to execute shell command from perl script but I
I would like to execute an OS command from my ruby script but I
How do I execute a command-line program from C# and get back the STD
I need to execute MDX query from command line (MS AS 2005). I have
How can I execute a terminal command (like grep ) from my Objective-C Cocoa
I am trying to execute this SQL command: SELECT page.page_namespace, pagelinks.pl_namespace, COUNT(*) FROM page,
I want to exceute a simple command which works from the shell but doesn't
I want to execute a command from an Ant buildfile, for each file in

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.