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

GetSysColor

関数
指定したシステム表示要素の色を取得する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll
#include <windows.h>

DWORD GetSysColor(
    SYS_COLOR_INDEX nIndex
);

パラメーター

名前方向
nIndexSYS_COLOR_INDEXin

戻り値の型: DWORD

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

DWORD GetSysColor(
    SYS_COLOR_INDEX nIndex
);
[DllImport("USER32.dll", ExactSpelling = true)]
static extern uint GetSysColor(
    int nIndex   // SYS_COLOR_INDEX
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function GetSysColor(
    nIndex As Integer   ' SYS_COLOR_INDEX
) As UInteger
End Function
' nIndex : SYS_COLOR_INDEX
Declare PtrSafe Function GetSysColor Lib "user32" ( _
    ByVal nIndex As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetSysColor = ctypes.windll.user32.GetSysColor
GetSysColor.restype = wintypes.DWORD
GetSysColor.argtypes = [
    ctypes.c_int,  # nIndex : SYS_COLOR_INDEX
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
GetSysColor = Fiddle::Function.new(
  lib['GetSysColor'],
  [
    Fiddle::TYPE_INT,  # nIndex : SYS_COLOR_INDEX
  ],
  -Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GetSysColor(
        nIndex: i32  // SYS_COLOR_INDEX
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll")]
public static extern uint GetSysColor(int nIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetSysColor' -Namespace Win32 -PassThru
# $api::GetSysColor(nIndex)
#uselib "USER32.dll"
#func global GetSysColor "GetSysColor" sptr
; GetSysColor nIndex   ; 戻り値は stat
; nIndex : SYS_COLOR_INDEX -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global GetSysColor "GetSysColor" int
; res = GetSysColor(nIndex)
; nIndex : SYS_COLOR_INDEX -> "int"
; DWORD GetSysColor(SYS_COLOR_INDEX nIndex)
#uselib "USER32.dll"
#cfunc global GetSysColor "GetSysColor" int
; res = GetSysColor(nIndex)
; nIndex : SYS_COLOR_INDEX -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetSysColor = user32.NewProc("GetSysColor")
)

// nIndex (SYS_COLOR_INDEX)
r1, _, err := procGetSysColor.Call(
	uintptr(nIndex),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetSysColor(
  nIndex: Integer   // SYS_COLOR_INDEX
): DWORD; stdcall;
  external 'USER32.dll' name 'GetSysColor';
result := DllCall("USER32\GetSysColor"
    , "Int", nIndex   ; SYS_COLOR_INDEX
    , "UInt")   ; return: DWORD
●GetSysColor(nIndex) = DLL("USER32.dll", "dword GetSysColor(int)")
# 呼び出し: GetSysColor(nIndex)
# nIndex : SYS_COLOR_INDEX -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。