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

DdeCreateDataHandle

関数
指定データから新しいDDEデータハンドルを作成する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HDDEDATA DdeCreateDataHandle(
    DWORD idInst,
    BYTE* pSrc,   // optional
    DWORD cb,
    DWORD cbOff,
    HSZ hszItem,   // optional
    DWORD wFmt,
    DWORD afCmd
);

パラメーター

名前方向
idInstDWORDin
pSrcBYTE*inoptional
cbDWORDin
cbOffDWORDin
hszItemHSZinoptional
wFmtDWORDin
afCmdDWORDin

戻り値の型: HDDEDATA

各言語での呼び出し定義

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

HDDEDATA DdeCreateDataHandle(
    DWORD idInst,
    BYTE* pSrc,   // optional
    DWORD cb,
    DWORD cbOff,
    HSZ hszItem,   // optional
    DWORD wFmt,
    DWORD afCmd
);
[DllImport("USER32.dll", ExactSpelling = true)]
static extern IntPtr DdeCreateDataHandle(
    uint idInst,   // DWORD
    IntPtr pSrc,   // BYTE* optional
    uint cb,   // DWORD
    uint cbOff,   // DWORD
    IntPtr hszItem,   // HSZ optional
    uint wFmt,   // DWORD
    uint afCmd   // DWORD
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function DdeCreateDataHandle(
    idInst As UInteger,   ' DWORD
    pSrc As IntPtr,   ' BYTE* optional
    cb As UInteger,   ' DWORD
    cbOff As UInteger,   ' DWORD
    hszItem As IntPtr,   ' HSZ optional
    wFmt As UInteger,   ' DWORD
    afCmd As UInteger   ' DWORD
) As IntPtr
End Function
' idInst : DWORD
' pSrc : BYTE* optional
' cb : DWORD
' cbOff : DWORD
' hszItem : HSZ optional
' wFmt : DWORD
' afCmd : DWORD
Declare PtrSafe Function DdeCreateDataHandle Lib "user32" ( _
    ByVal idInst As Long, _
    ByVal pSrc As LongPtr, _
    ByVal cb As Long, _
    ByVal cbOff As Long, _
    ByVal hszItem As LongPtr, _
    ByVal wFmt As Long, _
    ByVal afCmd As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DdeCreateDataHandle = ctypes.windll.user32.DdeCreateDataHandle
DdeCreateDataHandle.restype = ctypes.c_void_p
DdeCreateDataHandle.argtypes = [
    wintypes.DWORD,  # idInst : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # pSrc : BYTE* optional
    wintypes.DWORD,  # cb : DWORD
    wintypes.DWORD,  # cbOff : DWORD
    wintypes.HANDLE,  # hszItem : HSZ optional
    wintypes.DWORD,  # wFmt : DWORD
    wintypes.DWORD,  # afCmd : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
DdeCreateDataHandle = Fiddle::Function.new(
  lib['DdeCreateDataHandle'],
  [
    -Fiddle::TYPE_INT,  # idInst : DWORD
    Fiddle::TYPE_VOIDP,  # pSrc : BYTE* optional
    -Fiddle::TYPE_INT,  # cb : DWORD
    -Fiddle::TYPE_INT,  # cbOff : DWORD
    Fiddle::TYPE_VOIDP,  # hszItem : HSZ optional
    -Fiddle::TYPE_INT,  # wFmt : DWORD
    -Fiddle::TYPE_INT,  # afCmd : DWORD
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "user32")]
extern "system" {
    fn DdeCreateDataHandle(
        idInst: u32,  // DWORD
        pSrc: *mut u8,  // BYTE* optional
        cb: u32,  // DWORD
        cbOff: u32,  // DWORD
        hszItem: *mut core::ffi::c_void,  // HSZ optional
        wFmt: u32,  // DWORD
        afCmd: u32  // DWORD
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll")]
public static extern IntPtr DdeCreateDataHandle(uint idInst, IntPtr pSrc, uint cb, uint cbOff, IntPtr hszItem, uint wFmt, uint afCmd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DdeCreateDataHandle' -Namespace Win32 -PassThru
# $api::DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd)
#uselib "USER32.dll"
#func global DdeCreateDataHandle "DdeCreateDataHandle" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DdeCreateDataHandle idInst, varptr(pSrc), cb, cbOff, hszItem, wFmt, afCmd   ; 戻り値は stat
; idInst : DWORD -> "sptr"
; pSrc : BYTE* optional -> "sptr"
; cb : DWORD -> "sptr"
; cbOff : DWORD -> "sptr"
; hszItem : HSZ optional -> "sptr"
; wFmt : DWORD -> "sptr"
; afCmd : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global DdeCreateDataHandle "DdeCreateDataHandle" int, var, int, int, sptr, int, int
; res = DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd)
; idInst : DWORD -> "int"
; pSrc : BYTE* optional -> "var"
; cb : DWORD -> "int"
; cbOff : DWORD -> "int"
; hszItem : HSZ optional -> "sptr"
; wFmt : DWORD -> "int"
; afCmd : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HDDEDATA DdeCreateDataHandle(DWORD idInst, BYTE* pSrc, DWORD cb, DWORD cbOff, HSZ hszItem, DWORD wFmt, DWORD afCmd)
#uselib "USER32.dll"
#cfunc global DdeCreateDataHandle "DdeCreateDataHandle" int, var, int, int, intptr, int, int
; res = DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd)
; idInst : DWORD -> "int"
; pSrc : BYTE* optional -> "var"
; cb : DWORD -> "int"
; cbOff : DWORD -> "int"
; hszItem : HSZ optional -> "intptr"
; wFmt : DWORD -> "int"
; afCmd : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDdeCreateDataHandle = user32.NewProc("DdeCreateDataHandle")
)

// idInst (DWORD), pSrc (BYTE* optional), cb (DWORD), cbOff (DWORD), hszItem (HSZ optional), wFmt (DWORD), afCmd (DWORD)
r1, _, err := procDdeCreateDataHandle.Call(
	uintptr(idInst),
	uintptr(pSrc),
	uintptr(cb),
	uintptr(cbOff),
	uintptr(hszItem),
	uintptr(wFmt),
	uintptr(afCmd),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HDDEDATA
function DdeCreateDataHandle(
  idInst: DWORD;   // DWORD
  pSrc: Pointer;   // BYTE* optional
  cb: DWORD;   // DWORD
  cbOff: DWORD;   // DWORD
  hszItem: THandle;   // HSZ optional
  wFmt: DWORD;   // DWORD
  afCmd: DWORD   // DWORD
): THandle; stdcall;
  external 'USER32.dll' name 'DdeCreateDataHandle';
result := DllCall("USER32\DdeCreateDataHandle"
    , "UInt", idInst   ; DWORD
    , "Ptr", pSrc   ; BYTE* optional
    , "UInt", cb   ; DWORD
    , "UInt", cbOff   ; DWORD
    , "Ptr", hszItem   ; HSZ optional
    , "UInt", wFmt   ; DWORD
    , "UInt", afCmd   ; DWORD
    , "Ptr")   ; return: HDDEDATA
●DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd) = DLL("USER32.dll", "void* DdeCreateDataHandle(dword, void*, dword, dword, void*, dword, dword)")
# 呼び出し: DdeCreateDataHandle(idInst, pSrc, cb, cbOff, hszItem, wFmt, afCmd)
# idInst : DWORD -> "dword"
# pSrc : BYTE* optional -> "void*"
# cb : DWORD -> "dword"
# cbOff : DWORD -> "dword"
# hszItem : HSZ optional -> "void*"
# wFmt : DWORD -> "dword"
# afCmd : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。