ホーム › System.DataExchange › RegisterClipboardFormatW
RegisterClipboardFormatW
関数新しいクリップボード形式を登録しIDを取得する(Unicode版)。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
DWORD RegisterClipboardFormatW(
LPCWSTR lpszFormat
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpszFormat | LPCWSTR | in |
戻り値の型: DWORD
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
DWORD RegisterClipboardFormatW(
LPCWSTR lpszFormat
);[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern uint RegisterClipboardFormatW(
[MarshalAs(UnmanagedType.LPWStr)] string lpszFormat // LPCWSTR
);<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function RegisterClipboardFormatW(
<MarshalAs(UnmanagedType.LPWStr)> lpszFormat As String ' LPCWSTR
) As UInteger
End Function' lpszFormat : LPCWSTR
Declare PtrSafe Function RegisterClipboardFormatW Lib "user32" ( _
ByVal lpszFormat As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterClipboardFormatW = ctypes.windll.user32.RegisterClipboardFormatW
RegisterClipboardFormatW.restype = wintypes.DWORD
RegisterClipboardFormatW.argtypes = [
wintypes.LPCWSTR, # lpszFormat : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
RegisterClipboardFormatW = Fiddle::Function.new(
lib['RegisterClipboardFormatW'],
[
Fiddle::TYPE_VOIDP, # lpszFormat : LPCWSTR
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn RegisterClipboardFormatW(
lpszFormat: *const u16 // LPCWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint RegisterClipboardFormatW([MarshalAs(UnmanagedType.LPWStr)] string lpszFormat);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_RegisterClipboardFormatW' -Namespace Win32 -PassThru
# $api::RegisterClipboardFormatW(lpszFormat)#uselib "USER32.dll"
#func global RegisterClipboardFormatW "RegisterClipboardFormatW" wptr
; RegisterClipboardFormatW lpszFormat ; 戻り値は stat
; lpszFormat : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global RegisterClipboardFormatW "RegisterClipboardFormatW" wstr
; res = RegisterClipboardFormatW(lpszFormat)
; lpszFormat : LPCWSTR -> "wstr"; DWORD RegisterClipboardFormatW(LPCWSTR lpszFormat)
#uselib "USER32.dll"
#cfunc global RegisterClipboardFormatW "RegisterClipboardFormatW" wstr
; res = RegisterClipboardFormatW(lpszFormat)
; lpszFormat : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procRegisterClipboardFormatW = user32.NewProc("RegisterClipboardFormatW")
)
// lpszFormat (LPCWSTR)
r1, _, err := procRegisterClipboardFormatW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszFormat))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RegisterClipboardFormatW(
lpszFormat: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'USER32.dll' name 'RegisterClipboardFormatW';result := DllCall("USER32\RegisterClipboardFormatW"
, "WStr", lpszFormat ; LPCWSTR
, "UInt") ; return: DWORD●RegisterClipboardFormatW(lpszFormat) = DLL("USER32.dll", "dword RegisterClipboardFormatW(char*)")
# 呼び出し: RegisterClipboardFormatW(lpszFormat)
# lpszFormat : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。