Win32 API 日本語リファレンス
ホームGraphics.Gdi › GrayStringA

GrayStringA

関数
文字列を淡色化して指定位置に描画する(ANSI版)。
DLLUSER32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (ANSI / -A)
#include <windows.h>

BOOL GrayStringA(
    HDC hDC,
    HBRUSH hBrush,   // optional
    GRAYSTRINGPROC lpOutputFunc,   // optional
    LPARAM lpData,
    INT nCount,
    INT X,
    INT Y,
    INT nWidth,
    INT nHeight
);

パラメーター

名前方向説明
hDCHDCinデバイスコンテキストへのハンドルです。
hBrushHBRUSHinoptionalグレー表示に使用するブラシへのハンドルです。このパラメーターが NULL の場合、ウィンドウテキストの描画に使用されたものと同じブラシでテキストがグレー表示されます。
lpOutputFuncGRAYSTRINGPROCinoptional文字列を描画するアプリケーション定義の関数へのポインターです。文字列の描画に TextOut を使用する場合は NULL ポインターになります。詳細については、OutputProc コールバック関数を参照してください。
lpDataLPARAMin出力関数に渡すデータへのポインターです。lpOutputFunc パラメーターが NULL の場合、lpData は出力する文字列へのポインターである必要があります。
nCountINTin出力する文字数です。nCount パラメーターが 0 の場合、GrayString は文字列の長さを計算します(lpData が文字列へのポインターであることを前提とします)。nCount が 1 で、lpOutputFunc が指す関数が FALSE を返す場合、画像は表示されますがグレー表示にはなりません。
XINTin文字列を囲む四角形の開始位置のデバイス x 座標です。
YINTin文字列を囲む四角形の開始位置のデバイス y 座標です。
nWidthINTin文字列を囲む四角形の幅(デバイス単位)です。このパラメーターが 0 の場合、GrayString は領域の幅を計算します(lpData が文字列へのポインターであることを前提とします)。
nHeightINTin文字列を囲む四角形の高さ(デバイス単位)です。このパラメーターが 0 の場合、GrayString は領域の高さを計算します(lpData が文字列へのポインターであることを前提とします)。

戻り値の型: BOOL

公式ドキュメント

GrayString 関数は、指定された位置にグレー表示のテキストを描画します。(ANSI)

戻り値

文字列が描画された場合、戻り値は 0 以外になります。

TextOut 関数またはアプリケーション定義の出力関数が 0 を返した場合、あるいはグレー表示用のメモリビットマップを作成するためのメモリが不足していた場合、戻り値は 0 になります。

解説(Remarks)

GrayString を呼び出さなくても、純粋なグレー色をサポートするデバイスでは、アプリケーションはグレー表示の文字列を描画できます。システムカラー COLOR_GRAYTEXT は、無効化されたテキストの描画に使用される純粋なグレーのシステムカラーです。アプリケーションは GetSysColor 関数を呼び出して COLOR_GRAYTEXT の色の値を取得できます。色が 0(黒)以外の場合、アプリケーションは SetTextColor 関数を呼び出してテキストの色をその色の値に設定し、文字列を直接描画できます。取得した色が黒の場合、アプリケーションはテキストをグレー表示にするために GrayString を呼び出す必要があります。

メモ

winuser.h ヘッダーは GrayString を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不整合が生じ、コンパイルエラーや実行時エラーが発生する可能性があります。詳細については、関数プロトタイプの規則を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// USER32.dll  (ANSI / -A)
#include <windows.h>

BOOL GrayStringA(
    HDC hDC,
    HBRUSH hBrush,   // optional
    GRAYSTRINGPROC lpOutputFunc,   // optional
    LPARAM lpData,
    INT nCount,
    INT X,
    INT Y,
    INT nWidth,
    INT nHeight
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool GrayStringA(
    IntPtr hDC,   // HDC
    IntPtr hBrush,   // HBRUSH optional
    IntPtr lpOutputFunc,   // GRAYSTRINGPROC optional
    IntPtr lpData,   // LPARAM
    int nCount,   // INT
    int X,   // INT
    int Y,   // INT
    int nWidth,   // INT
    int nHeight   // INT
);
<DllImport("USER32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GrayStringA(
    hDC As IntPtr,   ' HDC
    hBrush As IntPtr,   ' HBRUSH optional
    lpOutputFunc As IntPtr,   ' GRAYSTRINGPROC optional
    lpData As IntPtr,   ' LPARAM
    nCount As Integer,   ' INT
    X As Integer,   ' INT
    Y As Integer,   ' INT
    nWidth As Integer,   ' INT
    nHeight As Integer   ' INT
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hDC : HDC
' hBrush : HBRUSH optional
' lpOutputFunc : GRAYSTRINGPROC optional
' lpData : LPARAM
' nCount : INT
' X : INT
' Y : INT
' nWidth : INT
' nHeight : INT
Declare PtrSafe Function GrayStringA Lib "user32" ( _
    ByVal hDC As LongPtr, _
    ByVal hBrush As LongPtr, _
    ByVal lpOutputFunc As LongPtr, _
    ByVal lpData As LongPtr, _
    ByVal nCount As Long, _
    ByVal X As Long, _
    ByVal Y As Long, _
    ByVal nWidth As Long, _
    ByVal nHeight As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GrayStringA = ctypes.windll.user32.GrayStringA
GrayStringA.restype = wintypes.BOOL
GrayStringA.argtypes = [
    wintypes.HANDLE,  # hDC : HDC
    wintypes.HANDLE,  # hBrush : HBRUSH optional
    ctypes.c_void_p,  # lpOutputFunc : GRAYSTRINGPROC optional
    ctypes.c_ssize_t,  # lpData : LPARAM
    ctypes.c_int,  # nCount : INT
    ctypes.c_int,  # X : INT
    ctypes.c_int,  # Y : INT
    ctypes.c_int,  # nWidth : INT
    ctypes.c_int,  # nHeight : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
GrayStringA = Fiddle::Function.new(
  lib['GrayStringA'],
  [
    Fiddle::TYPE_VOIDP,  # hDC : HDC
    Fiddle::TYPE_VOIDP,  # hBrush : HBRUSH optional
    Fiddle::TYPE_VOIDP,  # lpOutputFunc : GRAYSTRINGPROC optional
    Fiddle::TYPE_INTPTR_T,  # lpData : LPARAM
    Fiddle::TYPE_INT,  # nCount : INT
    Fiddle::TYPE_INT,  # X : INT
    Fiddle::TYPE_INT,  # Y : INT
    Fiddle::TYPE_INT,  # nWidth : INT
    Fiddle::TYPE_INT,  # nHeight : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GrayStringA(
        hDC: *mut core::ffi::c_void,  // HDC
        hBrush: *mut core::ffi::c_void,  // HBRUSH optional
        lpOutputFunc: *const core::ffi::c_void,  // GRAYSTRINGPROC optional
        lpData: isize,  // LPARAM
        nCount: i32,  // INT
        X: i32,  // INT
        Y: i32,  // INT
        nWidth: i32,  // INT
        nHeight: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi)]
public static extern bool GrayStringA(IntPtr hDC, IntPtr hBrush, IntPtr lpOutputFunc, IntPtr lpData, int nCount, int X, int Y, int nWidth, int nHeight);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GrayStringA' -Namespace Win32 -PassThru
# $api::GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
#uselib "USER32.dll"
#func global GrayStringA "GrayStringA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GrayStringA hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight   ; 戻り値は stat
; hDC : HDC -> "sptr"
; hBrush : HBRUSH optional -> "sptr"
; lpOutputFunc : GRAYSTRINGPROC optional -> "sptr"
; lpData : LPARAM -> "sptr"
; nCount : INT -> "sptr"
; X : INT -> "sptr"
; Y : INT -> "sptr"
; nWidth : INT -> "sptr"
; nHeight : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global GrayStringA "GrayStringA" sptr, sptr, sptr, sptr, int, int, int, int, int
; res = GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
; hDC : HDC -> "sptr"
; hBrush : HBRUSH optional -> "sptr"
; lpOutputFunc : GRAYSTRINGPROC optional -> "sptr"
; lpData : LPARAM -> "sptr"
; nCount : INT -> "int"
; X : INT -> "int"
; Y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; BOOL GrayStringA(HDC hDC, HBRUSH hBrush, GRAYSTRINGPROC lpOutputFunc, LPARAM lpData, INT nCount, INT X, INT Y, INT nWidth, INT nHeight)
#uselib "USER32.dll"
#cfunc global GrayStringA "GrayStringA" intptr, intptr, intptr, intptr, int, int, int, int, int
; res = GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
; hDC : HDC -> "intptr"
; hBrush : HBRUSH optional -> "intptr"
; lpOutputFunc : GRAYSTRINGPROC optional -> "intptr"
; lpData : LPARAM -> "intptr"
; nCount : INT -> "int"
; X : INT -> "int"
; Y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGrayStringA = user32.NewProc("GrayStringA")
)

// hDC (HDC), hBrush (HBRUSH optional), lpOutputFunc (GRAYSTRINGPROC optional), lpData (LPARAM), nCount (INT), X (INT), Y (INT), nWidth (INT), nHeight (INT)
r1, _, err := procGrayStringA.Call(
	uintptr(hDC),
	uintptr(hBrush),
	uintptr(lpOutputFunc),
	uintptr(lpData),
	uintptr(nCount),
	uintptr(X),
	uintptr(Y),
	uintptr(nWidth),
	uintptr(nHeight),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GrayStringA(
  hDC: THandle;   // HDC
  hBrush: THandle;   // HBRUSH optional
  lpOutputFunc: Pointer;   // GRAYSTRINGPROC optional
  lpData: NativeInt;   // LPARAM
  nCount: Integer;   // INT
  X: Integer;   // INT
  Y: Integer;   // INT
  nWidth: Integer;   // INT
  nHeight: Integer   // INT
): BOOL; stdcall;
  external 'USER32.dll' name 'GrayStringA';
result := DllCall("USER32\GrayStringA"
    , "Ptr", hDC   ; HDC
    , "Ptr", hBrush   ; HBRUSH optional
    , "Ptr", lpOutputFunc   ; GRAYSTRINGPROC optional
    , "Ptr", lpData   ; LPARAM
    , "Int", nCount   ; INT
    , "Int", X   ; INT
    , "Int", Y   ; INT
    , "Int", nWidth   ; INT
    , "Int", nHeight   ; INT
    , "Int")   ; return: BOOL
●GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight) = DLL("USER32.dll", "bool GrayStringA(void*, void*, void*, int, int, int, int, int, int)")
# 呼び出し: GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
# hDC : HDC -> "void*"
# hBrush : HBRUSH optional -> "void*"
# lpOutputFunc : GRAYSTRINGPROC optional -> "void*"
# lpData : LPARAM -> "int"
# nCount : INT -> "int"
# X : INT -> "int"
# Y : INT -> "int"
# nWidth : INT -> "int"
# nHeight : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "user32" fn GrayStringA(
    hDC: ?*anyopaque, // HDC
    hBrush: ?*anyopaque, // HBRUSH optional
    lpOutputFunc: ?*anyopaque, // GRAYSTRINGPROC optional
    lpData: isize, // LPARAM
    nCount: i32, // INT
    X: i32, // INT
    Y: i32, // INT
    nWidth: i32, // INT
    nHeight: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
proc GrayStringA(
    hDC: pointer,  # HDC
    hBrush: pointer,  # HBRUSH optional
    lpOutputFunc: pointer,  # GRAYSTRINGPROC optional
    lpData: int,  # LPARAM
    nCount: int32,  # INT
    X: int32,  # INT
    Y: int32,  # INT
    nWidth: int32,  # INT
    nHeight: int32  # INT
): int32 {.importc: "GrayStringA", stdcall, dynlib: "USER32.dll".}
pragma(lib, "user32");
extern(Windows)
int GrayStringA(
    void* hDC,   // HDC
    void* hBrush,   // HBRUSH optional
    void* lpOutputFunc,   // GRAYSTRINGPROC optional
    ptrdiff_t lpData,   // LPARAM
    int nCount,   // INT
    int X,   // INT
    int Y,   // INT
    int nWidth,   // INT
    int nHeight   // INT
);
ccall((:GrayStringA, "USER32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Int, Int32, Int32, Int32, Int32, Int32),
      hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
# hDC : HDC -> Ptr{Cvoid}
# hBrush : HBRUSH optional -> Ptr{Cvoid}
# lpOutputFunc : GRAYSTRINGPROC optional -> Ptr{Cvoid}
# lpData : LPARAM -> Int
# nCount : INT -> Int32
# X : INT -> Int32
# Y : INT -> Int32
# nWidth : INT -> Int32
# nHeight : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GrayStringA(
    void* hDC,
    void* hBrush,
    void* lpOutputFunc,
    intptr_t lpData,
    int32_t nCount,
    int32_t X,
    int32_t Y,
    int32_t nWidth,
    int32_t nHeight);
]]
local user32 = ffi.load("user32")
-- user32.GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
-- hDC : HDC
-- hBrush : HBRUSH optional
-- lpOutputFunc : GRAYSTRINGPROC optional
-- lpData : LPARAM
-- nCount : INT
-- X : INT
-- Y : INT
-- nWidth : INT
-- nHeight : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const GrayStringA = lib.func('__stdcall', 'GrayStringA', 'int32_t', ['void *', 'void *', 'void *', 'intptr_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t']);
// GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
// hDC : HDC -> 'void *'
// hBrush : HBRUSH optional -> 'void *'
// lpOutputFunc : GRAYSTRINGPROC optional -> 'void *'
// lpData : LPARAM -> 'intptr_t'
// nCount : INT -> 'int32_t'
// X : INT -> 'int32_t'
// Y : INT -> 'int32_t'
// nWidth : INT -> 'int32_t'
// nHeight : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("USER32.dll", {
  GrayStringA: { parameters: ["pointer", "pointer", "pointer", "isize", "i32", "i32", "i32", "i32", "i32"], result: "i32" },
});
// lib.symbols.GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight)
// hDC : HDC -> "pointer"
// hBrush : HBRUSH optional -> "pointer"
// lpOutputFunc : GRAYSTRINGPROC optional -> "pointer"
// lpData : LPARAM -> "isize"
// nCount : INT -> "i32"
// X : INT -> "i32"
// Y : INT -> "i32"
// nWidth : INT -> "i32"
// nHeight : INT -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GrayStringA(
    void* hDC,
    void* hBrush,
    void* lpOutputFunc,
    intptr_t lpData,
    int32_t nCount,
    int32_t X,
    int32_t Y,
    int32_t nWidth,
    int32_t nHeight);
C, "USER32.dll");
// $ffi->GrayStringA(hDC, hBrush, lpOutputFunc, lpData, nCount, X, Y, nWidth, nHeight);
// hDC : HDC
// hBrush : HBRUSH optional
// lpOutputFunc : GRAYSTRINGPROC optional
// lpData : LPARAM
// nCount : INT
// X : INT
// Y : INT
// nWidth : INT
// nHeight : INT
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface User32 extends StdCallLibrary {
    User32 INSTANCE = Native.load("user32", User32.class, W32APIOptions.ASCII_OPTIONS);
    boolean GrayStringA(
        Pointer hDC,   // HDC
        Pointer hBrush,   // HBRUSH optional
        Callback lpOutputFunc,   // GRAYSTRINGPROC optional
        long lpData,   // LPARAM
        int nCount,   // INT
        int X,   // INT
        int Y,   // INT
        int nWidth,   // INT
        int nHeight   // INT
    );
}
@[Link("user32")]
lib LibUSER32
  fun GrayStringA = GrayStringA(
    hDC : Void*,   # HDC
    hBrush : Void*,   # HBRUSH optional
    lpOutputFunc : Void*,   # GRAYSTRINGPROC optional
    lpData : LibC::SSizeT,   # LPARAM
    nCount : Int32,   # INT
    X : Int32,   # INT
    Y : Int32,   # INT
    nWidth : Int32,   # INT
    nHeight : Int32   # INT
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GrayStringANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, IntPtr, Int32, Int32, Int32, Int32, Int32);
typedef GrayStringADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int, int, int, int, int);
final GrayStringA = DynamicLibrary.open('USER32.dll')
    .lookupFunction<GrayStringANative, GrayStringADart>('GrayStringA');
// hDC : HDC -> Pointer<Void>
// hBrush : HBRUSH optional -> Pointer<Void>
// lpOutputFunc : GRAYSTRINGPROC optional -> Pointer<Void>
// lpData : LPARAM -> IntPtr
// nCount : INT -> Int32
// X : INT -> Int32
// Y : INT -> Int32
// nWidth : INT -> Int32
// nHeight : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GrayStringA(
  hDC: THandle;   // HDC
  hBrush: THandle;   // HBRUSH optional
  lpOutputFunc: Pointer;   // GRAYSTRINGPROC optional
  lpData: NativeInt;   // LPARAM
  nCount: Integer;   // INT
  X: Integer;   // INT
  Y: Integer;   // INT
  nWidth: Integer;   // INT
  nHeight: Integer   // INT
): BOOL; stdcall;
  external 'USER32.dll' name 'GrayStringA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GrayStringA"
  c_GrayStringA :: Ptr () -> Ptr () -> Ptr () -> CIntPtr -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO CInt
-- hDC : HDC -> Ptr ()
-- hBrush : HBRUSH optional -> Ptr ()
-- lpOutputFunc : GRAYSTRINGPROC optional -> Ptr ()
-- lpData : LPARAM -> CIntPtr
-- nCount : INT -> Int32
-- X : INT -> Int32
-- Y : INT -> Int32
-- nWidth : INT -> Int32
-- nHeight : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let graystringa =
  foreign "GrayStringA"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> intptr_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> returning int32_t)
(* hDC : HDC -> (ptr void) *)
(* hBrush : HBRUSH optional -> (ptr void) *)
(* lpOutputFunc : GRAYSTRINGPROC optional -> (ptr void) *)
(* lpData : LPARAM -> intptr_t *)
(* nCount : INT -> int32_t *)
(* X : INT -> int32_t *)
(* Y : INT -> int32_t *)
(* nWidth : INT -> int32_t *)
(* nHeight : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)

(cffi:defcfun ("GrayStringA" gray-string-a :convention :stdcall) :int32
  (h-dc :pointer)   ; HDC
  (h-brush :pointer)   ; HBRUSH optional
  (lp-output-func :pointer)   ; GRAYSTRINGPROC optional
  (lp-data :int64)   ; LPARAM
  (n-count :int32)   ; INT
  (x :int32)   ; INT
  (y :int32)   ; INT
  (n-width :int32)   ; INT
  (n-height :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GrayStringA = Win32::API::More->new('USER32',
    'BOOL GrayStringA(HANDLE hDC, HANDLE hBrush, LPVOID lpOutputFunc, LPARAM lpData, int nCount, int X, int Y, int nWidth, int nHeight)');
# my $ret = $GrayStringA->Call($hDC, $hBrush, $lpOutputFunc, $lpData, $nCount, $X, $Y, $nWidth, $nHeight);
# hDC : HDC -> HANDLE
# hBrush : HBRUSH optional -> HANDLE
# lpOutputFunc : GRAYSTRINGPROC optional -> LPVOID
# lpData : LPARAM -> LPARAM
# nCount : INT -> int
# X : INT -> int
# Y : INT -> int
# nWidth : INT -> int
# nHeight : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

文字セット違い
公式の関連項目
使用する型