S
S
seriouscope2021-10-28 23:21:58
C++ / C#
seriouscope, 2021-10-28 23:21:58

What is CreateWindowExA lpszClassName on the console?

Hello everyone, when I ran the code in the form

#include <windows.h>
#include <stdio.h>
int main() {
  LPWSTR className = NULL;
  GetClassNameW(GetActiveWindow(), className, 255);
  wprintf(L"%s", className);
}

Then I got null
Using spy++ in the class section I got the ConsoleWindowClass
which is then actually lpszClassName for the console

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-10-28
@seriouscope

I have not dealt with WinApi for a long time, but it seems that for console applications another function is needed instead of GetActiveWindow (). At the same time, fix the error with the lack of a buffer under className, as pointed out by 15432

WCHAR className[255];
  GetClassNameW(GetConsoleWindow(), className, 255);
  wprintf(L"%s", className);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question