Win32控制台写入(C/C+;+;) 我想在C++程序中向控制台写入,而不使用“STD”库,也就是说,只使用“Windows .h”中的函数。原因是我想深入研究可移植可执行文件,看看调用的是这一个函数,而不是一堆函数层。有人知道如何执行此操作和/或在哪里可以找到“Windows.h”函数的指南吗?
使用纯Win API:Win32控制台写入(C/C+;+;) 我想在C++程序中向控制台写入,而不使用“STD”库,也就是说,只使用“Windows .h”中的函数。原因是我想深入研究可移植可执行文件,看看调用的是这一个函数,而不是一堆函数层。有人知道如何执行此操作和/或在哪里可以找到“Windows.h”函数的指南吗?,c++,winapi,C++,Winapi,使用纯Win API: HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE); if (stdOut != NULL && stdOut != INVALID_HANDLE_VALUE) { DWORD written = 0; const char *message = "hello world"; WriteConsoleA(stdOut, message, strlen(message), &writ
HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (stdOut != NULL && stdOut != INVALID_HANDLE_VALUE)
{
DWORD written = 0;
const char *message = "hello world";
WriteConsoleA(stdOut, message, strlen(message), &written, NULL);
}
MSDN是您最好的文档来源之一:
HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (stdOut != NULL && stdOut != INVALID_HANDLE_VALUE)
{
DWORD written = 0;
const char *message = "hello world";
WriteConsoleA(stdOut, message, strlen(message), &written, NULL);
}
MSDN是您最好的文档来源之一:
#ifndef UNICODE
std::stringstream ss;
ss << TEXT("Hello world!") << std::endl;
OutputDebugString(ss.str().c_str());
OutputDebugStringA(ss.str().c_str());
#endif
#ifdef UNICODE
std::wstringstream wss;
wss << TEXT("Hello world!") << std::endl;
OutputDebugString(ss.str().c_str());
OutputDebugStringW(wss.str().c_str());
#endif
#ifndef UNICODE
std::stringstream-ss;
ss替代Win32 API:
#ifndef UNICODE
std::stringstream ss;
ss << TEXT("Hello world!") << std::endl;
OutputDebugString(ss.str().c_str());
OutputDebugStringA(ss.str().c_str());
#endif
#ifdef UNICODE
std::wstringstream wss;
wss << TEXT("Hello world!") << std::endl;
OutputDebugString(ss.str().c_str());
OutputDebugStringW(wss.str().c_str());
#endif
#ifndef UNICODE
std::stringstream-ss;
ss FWIW,对于写入控制台,有一个函数字面上称为WriteConsole
。它也有变体。FWIW,对于写入控制台,有一个函数字面上称为WriteConsole
。它也有变体。如果GetStdHandle
或WriteConsole
返回false,则可能需要使用alloconsole
。如果GetStdHandle
或WriteConsole
返回false,则可能需要使用alloconsole
。