ホーム › UI.ColorSystem › GetICMProfileA
GetICMProfileA
関数DCに関連付けられたICMプロファイル名を取得する(ANSI版)。
シグネチャ
// GDI32.dll (ANSI / -A)
#include <windows.h>
BOOL GetICMProfileA(
HDC hdc,
DWORD* pBufSize,
LPSTR pszFilename // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | ICMプロファイルを取得する対象デバイスコンテキストのハンドル。 |
| pBufSize | DWORD* | inout | 入力でバッファ文字数、出力で必要文字数を受け渡すDWORDへのポインター。 |
| pszFilename | LPSTR | outoptional | 現在のICMプロファイルのファイルパス(ANSI)を受け取るバッファへのポインター。 |
戻り値の型: BOOL
各言語での呼び出し定義
// GDI32.dll (ANSI / -A)
#include <windows.h>
BOOL GetICMProfileA(
HDC hdc,
DWORD* pBufSize,
LPSTR pszFilename // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool GetICMProfileA(
IntPtr hdc, // HDC
ref uint pBufSize, // DWORD* in/out
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszFilename // LPSTR optional, out
);<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetICMProfileA(
hdc As IntPtr, ' HDC
ByRef pBufSize As UInteger, ' DWORD* in/out
<MarshalAs(UnmanagedType.LPStr)> pszFilename As System.Text.StringBuilder ' LPSTR optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdc : HDC
' pBufSize : DWORD* in/out
' pszFilename : LPSTR optional, out
Declare PtrSafe Function GetICMProfileA Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByRef pBufSize As Long, _
ByVal pszFilename As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetICMProfileA = ctypes.windll.gdi32.GetICMProfileA
GetICMProfileA.restype = wintypes.BOOL
GetICMProfileA.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.POINTER(wintypes.DWORD), # pBufSize : DWORD* in/out
wintypes.LPSTR, # pszFilename : LPSTR optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
GetICMProfileA = Fiddle::Function.new(
lib['GetICMProfileA'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # pBufSize : DWORD* in/out
Fiddle::TYPE_VOIDP, # pszFilename : LPSTR optional, out
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn GetICMProfileA(
hdc: *mut core::ffi::c_void, // HDC
pBufSize: *mut u32, // DWORD* in/out
pszFilename: *mut u8 // LPSTR optional, out
) -> 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 GetICMProfileA(IntPtr hdc, ref uint pBufSize, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszFilename);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetICMProfileA' -Namespace Win32 -PassThru
# $api::GetICMProfileA(hdc, pBufSize, pszFilename)#uselib "GDI32.dll"
#func global GetICMProfileA "GetICMProfileA" sptr, sptr, sptr
; GetICMProfileA hdc, varptr(pBufSize), varptr(pszFilename) ; 戻り値は stat
; hdc : HDC -> "sptr"
; pBufSize : DWORD* in/out -> "sptr"
; pszFilename : LPSTR optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global GetICMProfileA "GetICMProfileA" sptr, var, var ; res = GetICMProfileA(hdc, pBufSize, pszFilename) ; hdc : HDC -> "sptr" ; pBufSize : DWORD* in/out -> "var" ; pszFilename : LPSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global GetICMProfileA "GetICMProfileA" sptr, sptr, sptr ; res = GetICMProfileA(hdc, varptr(pBufSize), varptr(pszFilename)) ; hdc : HDC -> "sptr" ; pBufSize : DWORD* in/out -> "sptr" ; pszFilename : LPSTR optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetICMProfileA(HDC hdc, DWORD* pBufSize, LPSTR pszFilename) #uselib "GDI32.dll" #cfunc global GetICMProfileA "GetICMProfileA" intptr, var, var ; res = GetICMProfileA(hdc, pBufSize, pszFilename) ; hdc : HDC -> "intptr" ; pBufSize : DWORD* in/out -> "var" ; pszFilename : LPSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetICMProfileA(HDC hdc, DWORD* pBufSize, LPSTR pszFilename) #uselib "GDI32.dll" #cfunc global GetICMProfileA "GetICMProfileA" intptr, intptr, intptr ; res = GetICMProfileA(hdc, varptr(pBufSize), varptr(pszFilename)) ; hdc : HDC -> "intptr" ; pBufSize : DWORD* in/out -> "intptr" ; pszFilename : LPSTR optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procGetICMProfileA = gdi32.NewProc("GetICMProfileA")
)
// hdc (HDC), pBufSize (DWORD* in/out), pszFilename (LPSTR optional, out)
r1, _, err := procGetICMProfileA.Call(
uintptr(hdc),
uintptr(pBufSize),
uintptr(pszFilename),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetICMProfileA(
hdc: THandle; // HDC
pBufSize: Pointer; // DWORD* in/out
pszFilename: PAnsiChar // LPSTR optional, out
): BOOL; stdcall;
external 'GDI32.dll' name 'GetICMProfileA';result := DllCall("GDI32\GetICMProfileA"
, "Ptr", hdc ; HDC
, "Ptr", pBufSize ; DWORD* in/out
, "Ptr", pszFilename ; LPSTR optional, out
, "Int") ; return: BOOL●GetICMProfileA(hdc, pBufSize, pszFilename) = DLL("GDI32.dll", "bool GetICMProfileA(void*, void*, char*)")
# 呼び出し: GetICMProfileA(hdc, pBufSize, pszFilename)
# hdc : HDC -> "void*"
# pBufSize : DWORD* in/out -> "void*"
# pszFilename : LPSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdi32" fn GetICMProfileA(
hdc: ?*anyopaque, // HDC
pBufSize: [*c]u32, // DWORD* in/out
pszFilename: [*c]u8 // LPSTR optional, out
) callconv(std.os.windows.WINAPI) i32;proc GetICMProfileA(
hdc: pointer, # HDC
pBufSize: ptr uint32, # DWORD* in/out
pszFilename: ptr char # LPSTR optional, out
): int32 {.importc: "GetICMProfileA", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
int GetICMProfileA(
void* hdc, // HDC
uint* pBufSize, // DWORD* in/out
char* pszFilename // LPSTR optional, out
);ccall((:GetICMProfileA, "GDI32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{UInt32}, Ptr{UInt8}),
hdc, pBufSize, pszFilename)
# hdc : HDC -> Ptr{Cvoid}
# pBufSize : DWORD* in/out -> Ptr{UInt32}
# pszFilename : LPSTR optional, out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetICMProfileA(
void* hdc,
uint32_t* pBufSize,
char* pszFilename);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.GetICMProfileA(hdc, pBufSize, pszFilename)
-- hdc : HDC
-- pBufSize : DWORD* in/out
-- pszFilename : LPSTR optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const GetICMProfileA = lib.func('__stdcall', 'GetICMProfileA', 'int32_t', ['void *', 'uint32_t *', 'char *']);
// GetICMProfileA(hdc, pBufSize, pszFilename)
// hdc : HDC -> 'void *'
// pBufSize : DWORD* in/out -> 'uint32_t *'
// pszFilename : LPSTR optional, out -> 'char *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
GetICMProfileA: { parameters: ["pointer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.GetICMProfileA(hdc, pBufSize, pszFilename)
// hdc : HDC -> "pointer"
// pBufSize : DWORD* in/out -> "pointer"
// pszFilename : LPSTR optional, out -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetICMProfileA(
void* hdc,
uint32_t* pBufSize,
char* pszFilename);
C, "GDI32.dll");
// $ffi->GetICMProfileA(hdc, pBufSize, pszFilename);
// hdc : HDC
// pBufSize : DWORD* in/out
// pszFilename : LPSTR optional, out
// 構造体/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 Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class, W32APIOptions.ASCII_OPTIONS);
boolean GetICMProfileA(
Pointer hdc, // HDC
IntByReference pBufSize, // DWORD* in/out
byte[] pszFilename // LPSTR optional, out
);
}@[Link("gdi32")]
lib LibGDI32
fun GetICMProfileA = GetICMProfileA(
hdc : Void*, # HDC
pBufSize : UInt32*, # DWORD* in/out
pszFilename : UInt8* # LPSTR optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetICMProfileANative = Int32 Function(Pointer<Void>, Pointer<Uint32>, Pointer<Utf8>);
typedef GetICMProfileADart = int Function(Pointer<Void>, Pointer<Uint32>, Pointer<Utf8>);
final GetICMProfileA = DynamicLibrary.open('GDI32.dll')
.lookupFunction<GetICMProfileANative, GetICMProfileADart>('GetICMProfileA');
// hdc : HDC -> Pointer<Void>
// pBufSize : DWORD* in/out -> Pointer<Uint32>
// pszFilename : LPSTR optional, out -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetICMProfileA(
hdc: THandle; // HDC
pBufSize: Pointer; // DWORD* in/out
pszFilename: PAnsiChar // LPSTR optional, out
): BOOL; stdcall;
external 'GDI32.dll' name 'GetICMProfileA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetICMProfileA"
c_GetICMProfileA :: Ptr () -> Ptr Word32 -> CString -> IO CInt
-- hdc : HDC -> Ptr ()
-- pBufSize : DWORD* in/out -> Ptr Word32
-- pszFilename : LPSTR optional, out -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let geticmprofilea =
foreign "GetICMProfileA"
((ptr void) @-> (ptr uint32_t) @-> string @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* pBufSize : DWORD* in/out -> (ptr uint32_t) *)
(* pszFilename : LPSTR optional, out -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("GetICMProfileA" get-icmprofile-a :convention :stdcall) :int32
(hdc :pointer) ; HDC
(p-buf-size :pointer) ; DWORD* in/out
(psz-filename :pointer)) ; LPSTR optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetICMProfileA = Win32::API::More->new('GDI32',
'BOOL GetICMProfileA(HANDLE hdc, LPVOID pBufSize, LPSTR pszFilename)');
# my $ret = $GetICMProfileA->Call($hdc, $pBufSize, $pszFilename);
# hdc : HDC -> HANDLE
# pBufSize : DWORD* in/out -> LPVOID
# pszFilename : LPSTR optional, out -> LPSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f GetICMProfileW (Unicode版) — DCに関連付けられたICMプロファイル名を取得する(Unicode版)。