繁体   English   中英

GetCurrentConsoleFont没有在范围内声明,我做错了什么?

[英]GetCurrentConsoleFont not declared in scope, what I do wrong?

一开始我有:

#include <sstream>
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <string>
#define _WIN32_WINNT 0x500 //tells that this is win 2000 or higher, without GetConsoleWindow would not work
#include <windows.h>

using namespace std;

int main() {
  PCONSOLE_FONT_INFO lpConsoleCurrentFont;
  GetCurrentConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE), false,  lpConsoleCurrentFont);
  return 0;
}

未记录的功能SetConsoleFont可以工作,但是GetCurrentConsoleFont编译失败,提示它未在此范围内声明。

-编辑:更改为自持代码。

GetCurrentConsoleFont至少是在NT4 +上导出的,MinGW标头一定是错误的。

尝试在您的#include之后添加以下代码:

#ifdef __cplusplus
extern "C" {
#endif
BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsoleOutput,BOOL bMaximumWindow,PCONSOLE_FONT_INFO lpConsoleCurrentFont);
#ifdef __cplusplus
}
#endif

您的代码也是错误的,应该是:

CONSOLE_FONT_INFO ConsoleFontInfo;
GetCurrentConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE), false,  &ConsoleFontInfo);

(每次看到PSOMETYPE作为参数时,通常都会在堆栈上分配一个SOMETYPE结构,并将指向该结构的指针作为参数传递)

汉斯的上述评论是正确的。 在wincon.h中未定义GetCurrentConsoleFont。 将以下行添加到wincon.h中以获得此功能:

布尔WINAPI GetCurrentConsoleFont(HANDLE,BOOL,PCONSOLE_FONT_INFO);

协调WINAPI GetConsoleFontSize(HANDLE,DWORD);

GetConsoleFontSize也丢失。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM