Win32 API 日本語リファレンス
ホームSystem.DataExchange › SetClipboardViewer

SetClipboardViewer

関数
クリップボードビューアチェーンにウィンドウを登録する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

HWND SetClipboardViewer(
    HWND hWndNewViewer
);

パラメーター

名前方向
hWndNewViewerHWNDin

戻り値の型: HWND

各言語での呼び出し定義

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

HWND SetClipboardViewer(
    HWND hWndNewViewer
);
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr SetClipboardViewer(
    IntPtr hWndNewViewer   // HWND
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetClipboardViewer(
    hWndNewViewer As IntPtr   ' HWND
) As IntPtr
End Function
' hWndNewViewer : HWND
Declare PtrSafe Function SetClipboardViewer Lib "user32" ( _
    ByVal hWndNewViewer As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetClipboardViewer = ctypes.windll.user32.SetClipboardViewer
SetClipboardViewer.restype = ctypes.c_void_p
SetClipboardViewer.argtypes = [
    wintypes.HANDLE,  # hWndNewViewer : HWND
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
SetClipboardViewer = Fiddle::Function.new(
  lib['SetClipboardViewer'],
  [
    Fiddle::TYPE_VOIDP,  # hWndNewViewer : HWND
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "user32")]
extern "system" {
    fn SetClipboardViewer(
        hWndNewViewer: *mut core::ffi::c_void  // HWND
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", SetLastError = true)]
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetClipboardViewer' -Namespace Win32 -PassThru
# $api::SetClipboardViewer(hWndNewViewer)
#uselib "USER32.dll"
#func global SetClipboardViewer "SetClipboardViewer" sptr
; SetClipboardViewer hWndNewViewer   ; 戻り値は stat
; hWndNewViewer : HWND -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global SetClipboardViewer "SetClipboardViewer" sptr
; res = SetClipboardViewer(hWndNewViewer)
; hWndNewViewer : HWND -> "sptr"
; HWND SetClipboardViewer(HWND hWndNewViewer)
#uselib "USER32.dll"
#cfunc global SetClipboardViewer "SetClipboardViewer" intptr
; res = SetClipboardViewer(hWndNewViewer)
; hWndNewViewer : HWND -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procSetClipboardViewer = user32.NewProc("SetClipboardViewer")
)

// hWndNewViewer (HWND)
r1, _, err := procSetClipboardViewer.Call(
	uintptr(hWndNewViewer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HWND
function SetClipboardViewer(
  hWndNewViewer: THandle   // HWND
): THandle; stdcall;
  external 'USER32.dll' name 'SetClipboardViewer';
result := DllCall("USER32\SetClipboardViewer"
    , "Ptr", hWndNewViewer   ; HWND
    , "Ptr")   ; return: HWND
●SetClipboardViewer(hWndNewViewer) = DLL("USER32.dll", "void* SetClipboardViewer(void*)")
# 呼び出し: SetClipboardViewer(hWndNewViewer)
# hWndNewViewer : HWND -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。