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

DdeKeepStringHandle

関数
DDE文字列ハンドルの参照カウントを増やして保持する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL DdeKeepStringHandle(
    DWORD idInst,
    HSZ hsz
);

パラメーター

名前方向
idInstDWORDin
hszHSZin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

DdeKeepStringHandle = ctypes.windll.user32.DdeKeepStringHandle
DdeKeepStringHandle.restype = wintypes.BOOL
DdeKeepStringHandle.argtypes = [
    wintypes.DWORD,  # idInst : DWORD
    wintypes.HANDLE,  # hsz : HSZ
]
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDdeKeepStringHandle = user32.NewProc("DdeKeepStringHandle")
)

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