ホーム › System.DataExchange › DdeConnect
DdeConnect
関数指定サービスとトピックでDDEサーバーとの会話を確立する。
シグネチャ
// USER32.dll
#include <windows.h>
HCONV DdeConnect(
DWORD idInst,
HSZ hszService,
HSZ hszTopic,
CONVCONTEXT* pCC // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| idInst | DWORD | in |
| hszService | HSZ | in |
| hszTopic | HSZ | in |
| pCC | CONVCONTEXT* | inoptional |
戻り値の型: HCONV
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
HCONV DdeConnect(
DWORD idInst,
HSZ hszService,
HSZ hszTopic,
CONVCONTEXT* pCC // optional
);[DllImport("USER32.dll", ExactSpelling = true)]
static extern IntPtr DdeConnect(
uint idInst, // DWORD
IntPtr hszService, // HSZ
IntPtr hszTopic, // HSZ
IntPtr pCC // CONVCONTEXT* optional
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function DdeConnect(
idInst As UInteger, ' DWORD
hszService As IntPtr, ' HSZ
hszTopic As IntPtr, ' HSZ
pCC As IntPtr ' CONVCONTEXT* optional
) As IntPtr
End Function' idInst : DWORD
' hszService : HSZ
' hszTopic : HSZ
' pCC : CONVCONTEXT* optional
Declare PtrSafe Function DdeConnect Lib "user32" ( _
ByVal idInst As Long, _
ByVal hszService As LongPtr, _
ByVal hszTopic As LongPtr, _
ByVal pCC As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DdeConnect = ctypes.windll.user32.DdeConnect
DdeConnect.restype = ctypes.c_void_p
DdeConnect.argtypes = [
wintypes.DWORD, # idInst : DWORD
wintypes.HANDLE, # hszService : HSZ
wintypes.HANDLE, # hszTopic : HSZ
ctypes.c_void_p, # pCC : CONVCONTEXT* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
DdeConnect = Fiddle::Function.new(
lib['DdeConnect'],
[
-Fiddle::TYPE_INT, # idInst : DWORD
Fiddle::TYPE_VOIDP, # hszService : HSZ
Fiddle::TYPE_VOIDP, # hszTopic : HSZ
Fiddle::TYPE_VOIDP, # pCC : CONVCONTEXT* optional
],
Fiddle::TYPE_VOIDP)#[link(name = "user32")]
extern "system" {
fn DdeConnect(
idInst: u32, // DWORD
hszService: *mut core::ffi::c_void, // HSZ
hszTopic: *mut core::ffi::c_void, // HSZ
pCC: *mut CONVCONTEXT // CONVCONTEXT* optional
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll")]
public static extern IntPtr DdeConnect(uint idInst, IntPtr hszService, IntPtr hszTopic, IntPtr pCC);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DdeConnect' -Namespace Win32 -PassThru
# $api::DdeConnect(idInst, hszService, hszTopic, pCC)#uselib "USER32.dll"
#func global DdeConnect "DdeConnect" sptr, sptr, sptr, sptr
; DdeConnect idInst, hszService, hszTopic, varptr(pCC) ; 戻り値は stat
; idInst : DWORD -> "sptr"
; hszService : HSZ -> "sptr"
; hszTopic : HSZ -> "sptr"
; pCC : CONVCONTEXT* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global DdeConnect "DdeConnect" int, sptr, sptr, var ; res = DdeConnect(idInst, hszService, hszTopic, pCC) ; idInst : DWORD -> "int" ; hszService : HSZ -> "sptr" ; hszTopic : HSZ -> "sptr" ; pCC : CONVCONTEXT* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global DdeConnect "DdeConnect" int, sptr, sptr, sptr ; res = DdeConnect(idInst, hszService, hszTopic, varptr(pCC)) ; idInst : DWORD -> "int" ; hszService : HSZ -> "sptr" ; hszTopic : HSZ -> "sptr" ; pCC : CONVCONTEXT* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HCONV DdeConnect(DWORD idInst, HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC) #uselib "USER32.dll" #cfunc global DdeConnect "DdeConnect" int, intptr, intptr, var ; res = DdeConnect(idInst, hszService, hszTopic, pCC) ; idInst : DWORD -> "int" ; hszService : HSZ -> "intptr" ; hszTopic : HSZ -> "intptr" ; pCC : CONVCONTEXT* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HCONV DdeConnect(DWORD idInst, HSZ hszService, HSZ hszTopic, CONVCONTEXT* pCC) #uselib "USER32.dll" #cfunc global DdeConnect "DdeConnect" int, intptr, intptr, intptr ; res = DdeConnect(idInst, hszService, hszTopic, varptr(pCC)) ; idInst : DWORD -> "int" ; hszService : HSZ -> "intptr" ; hszTopic : HSZ -> "intptr" ; pCC : CONVCONTEXT* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procDdeConnect = user32.NewProc("DdeConnect")
)
// idInst (DWORD), hszService (HSZ), hszTopic (HSZ), pCC (CONVCONTEXT* optional)
r1, _, err := procDdeConnect.Call(
uintptr(idInst),
uintptr(hszService),
uintptr(hszTopic),
uintptr(pCC),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HCONVfunction DdeConnect(
idInst: DWORD; // DWORD
hszService: THandle; // HSZ
hszTopic: THandle; // HSZ
pCC: Pointer // CONVCONTEXT* optional
): THandle; stdcall;
external 'USER32.dll' name 'DdeConnect';result := DllCall("USER32\DdeConnect"
, "UInt", idInst ; DWORD
, "Ptr", hszService ; HSZ
, "Ptr", hszTopic ; HSZ
, "Ptr", pCC ; CONVCONTEXT* optional
, "Ptr") ; return: HCONV●DdeConnect(idInst, hszService, hszTopic, pCC) = DLL("USER32.dll", "void* DdeConnect(dword, void*, void*, void*)")
# 呼び出し: DdeConnect(idInst, hszService, hszTopic, pCC)
# idInst : DWORD -> "dword"
# hszService : HSZ -> "void*"
# hszTopic : HSZ -> "void*"
# pCC : CONVCONTEXT* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。