小编And*_*ert的帖子

由于参数无效,GetConsoleScreenBufferInfoEx失败

我试图从控制台应用程序调用GetConsoleScreenBufferInfoEx函数.如果重要,该应用程序是在64位Windows 7上运行的32位应用程序.该语言是RealBasic.

我相信我已经正确定义了所有结构,并且缓冲区输出句柄适用于所调用的每个其他API函数:

  Declare Function GetConsoleScreenBufferInfoEx Lib "Kernel32" (cHandle As Integer, ByRef info As CONSOLE_SCREEN_BUFFER_INFOEX) As Boolean
  Declare Function GetLastError Lib "Kernel32" () As Integer
  Declare Function GetStdHandle Lib "Kernel32" (hIOStreamType As Integer) As Integer

  Const STD_OUTPUT_HANDLE = -11
  Dim stdHandle As Integer = GetStdHandle(STD_OUTPUT_HANDLE)

  Dim err As Integer
  Dim info As CONSOLE_SCREEN_BUFFER_INFOEX

  If GetConsoleScreenBufferInfoEx(stdHandle, info) Then
    Break
  Else
    err = GetLastError  //Always 87, Invalid parameter
    Break
  End If
Run Code Online (Sandbox Code Playgroud)

结构:

Structure CONSOLE_SCREEN_BUFFER_INFOEX
  cbSize As Integer
  dwSize As COORD …
Run Code Online (Sandbox Code Playgroud)

console winapi realbasic realstudio

4
推荐指数
1
解决办法
889
查看次数

为curl_easy_setopt函数定义的CURLOPT_*常量在哪里?

我几乎查看了libcurl源包中包含的每个文件,似乎无法找到定义CURLOPT_*选项的位置.我认为它们可能是整数,也许是一个枚举,但对于我的生活,我找不到它们.

我写的语言是RealBasic,如果这很重要的话.通常,当使用以CI编写的外部库时,需要手动查找和翻译#define标题中的各个块.但#define在我能做任何事之前,我必须知道这个街区在哪里!

libcurl

3
推荐指数
1
解决办法
783
查看次数

第二次调用 GetStdHandle 返回“无效”句柄

我试图将控制台的文本颜色设置为给定颜色,打印一行(或多行),然后将颜色方案更改回原来的颜色。这是我所拥有的:

Function SetConsoleTextColor(NewColor As UInt16) As UInt16
    Declare Function SetConsoleTextAttribute Lib "Kernel32" (hConsole As Integer, attribs As UInt16) As Boolean
    Declare Function GetStdHandle Lib "Kernel32" (hIOStreamType As Integer) As Integer
    Declare Function GetConsoleScreenBufferInfo Lib "Kernel32" (hConsole As Integer, ByRef buffinfo As CONSOLE_SCREEN_BUFFER_INFO) As Boolean
    Declare Sub CloseHandle Lib "Kernel32" (HWND As Integer)

    Const STD_OUTPUT_HANDLE = -12

    Dim conHandle As Integer = GetStdHandle(STD_OUTPUT_HANDLE)
    Dim buffInfo As CONSOLE_SCREEN_BUFFER_INFO  //A structure defined elsewhere
    If GetConsoleScreenBufferInfo(conHandle, buffInfo) Then
      Call SetConsoleTextAttribute(conHandle, NewColor)
      CloseHandle(conHandle)
      Return buffInfo.Attribute …
Run Code Online (Sandbox Code Playgroud)

winapi realbasic windows-console

2
推荐指数
1
解决办法
2060
查看次数