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

ImpersonateDdeClientWindow

関数
DDEサーバーがクライアントのセキュリティコンテキストになりすます。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

BOOL ImpersonateDdeClientWindow(
    HWND hWndClient,
    HWND hWndServer
);

パラメーター

名前方向
hWndClientHWNDin
hWndServerHWNDin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procImpersonateDdeClientWindow = user32.NewProc("ImpersonateDdeClientWindow")
)

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