Win32 API 日本語リファレンス
ホームUI.ColorSystem › SetICMProfileA

SetICMProfileA

関数
DCに使用するICMプロファイルを設定する(ANSI版)。
DLLGDI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL SetICMProfileA(
    HDC hdc,
    LPSTR lpFileName
);

パラメーター

名前方向
hdcHDCin
lpFileNameLPSTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetICMProfileA(
    HDC hdc,
    LPSTR lpFileName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool SetICMProfileA(
    IntPtr hdc,   // HDC
    [MarshalAs(UnmanagedType.LPStr)] string lpFileName   // LPSTR
);
<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SetICMProfileA(
    hdc As IntPtr,   ' HDC
    <MarshalAs(UnmanagedType.LPStr)> lpFileName As String   ' LPSTR
) As Boolean
End Function
' hdc : HDC
' lpFileName : LPSTR
Declare PtrSafe Function SetICMProfileA Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal lpFileName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetICMProfileA = ctypes.windll.gdi32.SetICMProfileA
SetICMProfileA.restype = wintypes.BOOL
SetICMProfileA.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.LPCSTR,  # lpFileName : LPSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procSetICMProfileA = gdi32.NewProc("SetICMProfileA")
)

// hdc (HDC), lpFileName (LPSTR)
r1, _, err := procSetICMProfileA.Call(
	uintptr(hdc),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpFileName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetICMProfileA(
  hdc: THandle;   // HDC
  lpFileName: PAnsiChar   // LPSTR
): BOOL; stdcall;
  external 'GDI32.dll' name 'SetICMProfileA';
result := DllCall("GDI32\SetICMProfileA"
    , "Ptr", hdc   ; HDC
    , "AStr", lpFileName   ; LPSTR
    , "Int")   ; return: BOOL
●SetICMProfileA(hdc, lpFileName) = DLL("GDI32.dll", "bool SetICMProfileA(void*, char*)")
# 呼び出し: SetICMProfileA(hdc, lpFileName)
# hdc : HDC -> "void*"
# lpFileName : LPSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。