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

DdeSetUserHandle

関数
DDE会話にアプリケーション定義のユーザーハンドルを関連付ける。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL DdeSetUserHandle(
    HCONV hConv,
    DWORD id,
    UINT_PTR hUser
);

パラメーター

名前方向
hConvHCONVin
idDWORDin
hUserUINT_PTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL DdeSetUserHandle(
    HCONV hConv,
    DWORD id,
    UINT_PTR hUser
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool DdeSetUserHandle(
    IntPtr hConv,   // HCONV
    uint id,   // DWORD
    UIntPtr hUser   // UINT_PTR
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function DdeSetUserHandle(
    hConv As IntPtr,   ' HCONV
    id As UInteger,   ' DWORD
    hUser As UIntPtr   ' UINT_PTR
) As Boolean
End Function
' hConv : HCONV
' id : DWORD
' hUser : UINT_PTR
Declare PtrSafe Function DdeSetUserHandle Lib "user32" ( _
    ByVal hConv As LongPtr, _
    ByVal id As Long, _
    ByVal hUser As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DdeSetUserHandle = ctypes.windll.user32.DdeSetUserHandle
DdeSetUserHandle.restype = wintypes.BOOL
DdeSetUserHandle.argtypes = [
    wintypes.HANDLE,  # hConv : HCONV
    wintypes.DWORD,  # id : DWORD
    ctypes.c_size_t,  # hUser : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
DdeSetUserHandle = Fiddle::Function.new(
  lib['DdeSetUserHandle'],
  [
    Fiddle::TYPE_VOIDP,  # hConv : HCONV
    -Fiddle::TYPE_INT,  # id : DWORD
    Fiddle::TYPE_UINTPTR_T,  # hUser : UINT_PTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn DdeSetUserHandle(
        hConv: *mut core::ffi::c_void,  // HCONV
        id: u32,  // DWORD
        hUser: usize  // UINT_PTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool DdeSetUserHandle(IntPtr hConv, uint id, UIntPtr hUser);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DdeSetUserHandle' -Namespace Win32 -PassThru
# $api::DdeSetUserHandle(hConv, id, hUser)
#uselib "USER32.dll"
#func global DdeSetUserHandle "DdeSetUserHandle" sptr, sptr, sptr
; DdeSetUserHandle hConv, id, hUser   ; 戻り値は stat
; hConv : HCONV -> "sptr"
; id : DWORD -> "sptr"
; hUser : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global DdeSetUserHandle "DdeSetUserHandle" sptr, int, sptr
; res = DdeSetUserHandle(hConv, id, hUser)
; hConv : HCONV -> "sptr"
; id : DWORD -> "int"
; hUser : UINT_PTR -> "sptr"
; BOOL DdeSetUserHandle(HCONV hConv, DWORD id, UINT_PTR hUser)
#uselib "USER32.dll"
#cfunc global DdeSetUserHandle "DdeSetUserHandle" intptr, int, intptr
; res = DdeSetUserHandle(hConv, id, hUser)
; hConv : HCONV -> "intptr"
; id : DWORD -> "int"
; hUser : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDdeSetUserHandle = user32.NewProc("DdeSetUserHandle")
)

// hConv (HCONV), id (DWORD), hUser (UINT_PTR)
r1, _, err := procDdeSetUserHandle.Call(
	uintptr(hConv),
	uintptr(id),
	uintptr(hUser),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DdeSetUserHandle(
  hConv: THandle;   // HCONV
  id: DWORD;   // DWORD
  hUser: NativeUInt   // UINT_PTR
): BOOL; stdcall;
  external 'USER32.dll' name 'DdeSetUserHandle';
result := DllCall("USER32\DdeSetUserHandle"
    , "Ptr", hConv   ; HCONV
    , "UInt", id   ; DWORD
    , "UPtr", hUser   ; UINT_PTR
    , "Int")   ; return: BOOL
●DdeSetUserHandle(hConv, id, hUser) = DLL("USER32.dll", "bool DdeSetUserHandle(void*, dword, int)")
# 呼び出し: DdeSetUserHandle(hConv, id, hUser)
# hConv : HCONV -> "void*"
# id : DWORD -> "dword"
# hUser : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。