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

ResizePalette

関数
論理パレットのエントリ数を変更する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL ResizePalette(
    HPALETTE hpal,
    DWORD n
);

パラメーター

名前方向
hpalHPALETTEin
nDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ResizePalette(
    HPALETTE hpal,
    DWORD n
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool ResizePalette(
    IntPtr hpal,   // HPALETTE
    uint n   // DWORD
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function ResizePalette(
    hpal As IntPtr,   ' HPALETTE
    n As UInteger   ' DWORD
) As Boolean
End Function
' hpal : HPALETTE
' n : DWORD
Declare PtrSafe Function ResizePalette Lib "gdi32" ( _
    ByVal hpal As LongPtr, _
    ByVal n As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResizePalette = ctypes.windll.gdi32.ResizePalette
ResizePalette.restype = wintypes.BOOL
ResizePalette.argtypes = [
    wintypes.HANDLE,  # hpal : HPALETTE
    wintypes.DWORD,  # n : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
ResizePalette = Fiddle::Function.new(
  lib['ResizePalette'],
  [
    Fiddle::TYPE_VOIDP,  # hpal : HPALETTE
    -Fiddle::TYPE_INT,  # n : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn ResizePalette(
        hpal: *mut core::ffi::c_void,  // HPALETTE
        n: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool ResizePalette(IntPtr hpal, uint n);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_ResizePalette' -Namespace Win32 -PassThru
# $api::ResizePalette(hpal, n)
#uselib "GDI32.dll"
#func global ResizePalette "ResizePalette" sptr, sptr
; ResizePalette hpal, n   ; 戻り値は stat
; hpal : HPALETTE -> "sptr"
; n : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global ResizePalette "ResizePalette" sptr, int
; res = ResizePalette(hpal, n)
; hpal : HPALETTE -> "sptr"
; n : DWORD -> "int"
; BOOL ResizePalette(HPALETTE hpal, DWORD n)
#uselib "GDI32.dll"
#cfunc global ResizePalette "ResizePalette" intptr, int
; res = ResizePalette(hpal, n)
; hpal : HPALETTE -> "intptr"
; n : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procResizePalette = gdi32.NewProc("ResizePalette")
)

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