ホーム › System.DataExchange › GetClipboardFormatNameA
GetClipboardFormatNameA
関数登録済みクリップボード形式の名前をANSI文字列で取得する。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
INT GetClipboardFormatNameA(
DWORD format,
LPSTR lpszFormatName,
INT cchMaxCount
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| format | DWORD | in |
| lpszFormatName | LPSTR | out |
| cchMaxCount | INT | in |
戻り値の型: INT
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
INT GetClipboardFormatNameA(
DWORD format,
LPSTR lpszFormatName,
INT cchMaxCount
);[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern int GetClipboardFormatNameA(
uint format, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszFormatName, // LPSTR out
int cchMaxCount // INT
);<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetClipboardFormatNameA(
format As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> lpszFormatName As System.Text.StringBuilder, ' LPSTR out
cchMaxCount As Integer ' INT
) As Integer
End Function' format : DWORD
' lpszFormatName : LPSTR out
' cchMaxCount : INT
Declare PtrSafe Function GetClipboardFormatNameA Lib "user32" ( _
ByVal format As Long, _
ByVal lpszFormatName As String, _
ByVal cchMaxCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetClipboardFormatNameA = ctypes.windll.user32.GetClipboardFormatNameA
GetClipboardFormatNameA.restype = ctypes.c_int
GetClipboardFormatNameA.argtypes = [
wintypes.DWORD, # format : DWORD
wintypes.LPSTR, # lpszFormatName : LPSTR out
ctypes.c_int, # cchMaxCount : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetClipboardFormatNameA = Fiddle::Function.new(
lib['GetClipboardFormatNameA'],
[
-Fiddle::TYPE_INT, # format : DWORD
Fiddle::TYPE_VOIDP, # lpszFormatName : LPSTR out
Fiddle::TYPE_INT, # cchMaxCount : INT
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetClipboardFormatNameA(
format: u32, // DWORD
lpszFormatName: *mut u8, // LPSTR out
cchMaxCount: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int GetClipboardFormatNameA(uint format, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszFormatName, int cchMaxCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetClipboardFormatNameA' -Namespace Win32 -PassThru
# $api::GetClipboardFormatNameA(format, lpszFormatName, cchMaxCount)#uselib "USER32.dll"
#func global GetClipboardFormatNameA "GetClipboardFormatNameA" sptr, sptr, sptr
; GetClipboardFormatNameA format, varptr(lpszFormatName), cchMaxCount ; 戻り値は stat
; format : DWORD -> "sptr"
; lpszFormatName : LPSTR out -> "sptr"
; cchMaxCount : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetClipboardFormatNameA "GetClipboardFormatNameA" int, var, int ; res = GetClipboardFormatNameA(format, lpszFormatName, cchMaxCount) ; format : DWORD -> "int" ; lpszFormatName : LPSTR out -> "var" ; cchMaxCount : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetClipboardFormatNameA "GetClipboardFormatNameA" int, sptr, int ; res = GetClipboardFormatNameA(format, varptr(lpszFormatName), cchMaxCount) ; format : DWORD -> "int" ; lpszFormatName : LPSTR out -> "sptr" ; cchMaxCount : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT GetClipboardFormatNameA(DWORD format, LPSTR lpszFormatName, INT cchMaxCount) #uselib "USER32.dll" #cfunc global GetClipboardFormatNameA "GetClipboardFormatNameA" int, var, int ; res = GetClipboardFormatNameA(format, lpszFormatName, cchMaxCount) ; format : DWORD -> "int" ; lpszFormatName : LPSTR out -> "var" ; cchMaxCount : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT GetClipboardFormatNameA(DWORD format, LPSTR lpszFormatName, INT cchMaxCount) #uselib "USER32.dll" #cfunc global GetClipboardFormatNameA "GetClipboardFormatNameA" int, intptr, int ; res = GetClipboardFormatNameA(format, varptr(lpszFormatName), cchMaxCount) ; format : DWORD -> "int" ; lpszFormatName : LPSTR out -> "intptr" ; cchMaxCount : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetClipboardFormatNameA = user32.NewProc("GetClipboardFormatNameA")
)
// format (DWORD), lpszFormatName (LPSTR out), cchMaxCount (INT)
r1, _, err := procGetClipboardFormatNameA.Call(
uintptr(format),
uintptr(lpszFormatName),
uintptr(cchMaxCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetClipboardFormatNameA(
format: DWORD; // DWORD
lpszFormatName: PAnsiChar; // LPSTR out
cchMaxCount: Integer // INT
): Integer; stdcall;
external 'USER32.dll' name 'GetClipboardFormatNameA';result := DllCall("USER32\GetClipboardFormatNameA"
, "UInt", format ; DWORD
, "Ptr", lpszFormatName ; LPSTR out
, "Int", cchMaxCount ; INT
, "Int") ; return: INT●GetClipboardFormatNameA(format, lpszFormatName, cchMaxCount) = DLL("USER32.dll", "int GetClipboardFormatNameA(dword, char*, int)")
# 呼び出し: GetClipboardFormatNameA(format, lpszFormatName, cchMaxCount)
# format : DWORD -> "dword"
# lpszFormatName : LPSTR out -> "char*"
# cchMaxCount : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。