Win32 API 日本語リファレンス
ホームMedia.Multimedia › DrawDibSetPalette

DrawDibSetPalette

関数
DrawDibで使用するパレットを設定する。
DLLMSVFW32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL DrawDibSetPalette(
    INT_PTR hdd,
    HPALETTE hpal   // optional
);

パラメーター

名前方向
hddINT_PTRin
hpalHPALETTEinoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

DrawDibSetPalette = ctypes.windll.msvfw32.DrawDibSetPalette
DrawDibSetPalette.restype = wintypes.BOOL
DrawDibSetPalette.argtypes = [
    ctypes.c_ssize_t,  # hdd : INT_PTR
    wintypes.HANDLE,  # hpal : HPALETTE optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msvfw32 = windows.NewLazySystemDLL("MSVFW32.dll")
	procDrawDibSetPalette = msvfw32.NewProc("DrawDibSetPalette")
)

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