Win32 API 日本語リファレンス
ホームDevices.WebServicesOnDevices › WSDCreateDeviceProxyAdvanced

WSDCreateDeviceProxyAdvanced

関数
アドレスを指定してWSDデバイスプロキシを作成する拡張版。
DLLwsdapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WSDCreateDeviceProxyAdvanced(
    LPCWSTR pszDeviceId,
    IWSDAddress* pDeviceAddress,
    LPCWSTR pszLocalId,
    IWSDXMLContext* pContext,
    IWSDDeviceProxy** ppDeviceProxy
);

パラメーター

名前方向
pszDeviceIdLPCWSTRin
pDeviceAddressIWSDAddress*in
pszLocalIdLPCWSTRin
pContextIWSDXMLContext*in
ppDeviceProxyIWSDDeviceProxy**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WSDCreateDeviceProxyAdvanced(
    LPCWSTR pszDeviceId,
    IWSDAddress* pDeviceAddress,
    LPCWSTR pszLocalId,
    IWSDXMLContext* pContext,
    IWSDDeviceProxy** ppDeviceProxy
);
[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern int WSDCreateDeviceProxyAdvanced(
    [MarshalAs(UnmanagedType.LPWStr)] string pszDeviceId,   // LPCWSTR
    IntPtr pDeviceAddress,   // IWSDAddress*
    [MarshalAs(UnmanagedType.LPWStr)] string pszLocalId,   // LPCWSTR
    IntPtr pContext,   // IWSDXMLContext*
    IntPtr ppDeviceProxy   // IWSDDeviceProxy** out
);
<DllImport("wsdapi.dll", ExactSpelling:=True)>
Public Shared Function WSDCreateDeviceProxyAdvanced(
    <MarshalAs(UnmanagedType.LPWStr)> pszDeviceId As String,   ' LPCWSTR
    pDeviceAddress As IntPtr,   ' IWSDAddress*
    <MarshalAs(UnmanagedType.LPWStr)> pszLocalId As String,   ' LPCWSTR
    pContext As IntPtr,   ' IWSDXMLContext*
    ppDeviceProxy As IntPtr   ' IWSDDeviceProxy** out
) As Integer
End Function
' pszDeviceId : LPCWSTR
' pDeviceAddress : IWSDAddress*
' pszLocalId : LPCWSTR
' pContext : IWSDXMLContext*
' ppDeviceProxy : IWSDDeviceProxy** out
Declare PtrSafe Function WSDCreateDeviceProxyAdvanced Lib "wsdapi" ( _
    ByVal pszDeviceId As LongPtr, _
    ByVal pDeviceAddress As LongPtr, _
    ByVal pszLocalId As LongPtr, _
    ByVal pContext As LongPtr, _
    ByVal ppDeviceProxy As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WSDCreateDeviceProxyAdvanced = ctypes.windll.wsdapi.WSDCreateDeviceProxyAdvanced
WSDCreateDeviceProxyAdvanced.restype = ctypes.c_int
WSDCreateDeviceProxyAdvanced.argtypes = [
    wintypes.LPCWSTR,  # pszDeviceId : LPCWSTR
    ctypes.c_void_p,  # pDeviceAddress : IWSDAddress*
    wintypes.LPCWSTR,  # pszLocalId : LPCWSTR
    ctypes.c_void_p,  # pContext : IWSDXMLContext*
    ctypes.c_void_p,  # ppDeviceProxy : IWSDDeviceProxy** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wsdapi.dll')
WSDCreateDeviceProxyAdvanced = Fiddle::Function.new(
  lib['WSDCreateDeviceProxyAdvanced'],
  [
    Fiddle::TYPE_VOIDP,  # pszDeviceId : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pDeviceAddress : IWSDAddress*
    Fiddle::TYPE_VOIDP,  # pszLocalId : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pContext : IWSDXMLContext*
    Fiddle::TYPE_VOIDP,  # ppDeviceProxy : IWSDDeviceProxy** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wsdapi")]
extern "system" {
    fn WSDCreateDeviceProxyAdvanced(
        pszDeviceId: *const u16,  // LPCWSTR
        pDeviceAddress: *mut core::ffi::c_void,  // IWSDAddress*
        pszLocalId: *const u16,  // LPCWSTR
        pContext: *mut core::ffi::c_void,  // IWSDXMLContext*
        ppDeviceProxy: *mut *mut core::ffi::c_void  // IWSDDeviceProxy** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wsdapi.dll")]
public static extern int WSDCreateDeviceProxyAdvanced([MarshalAs(UnmanagedType.LPWStr)] string pszDeviceId, IntPtr pDeviceAddress, [MarshalAs(UnmanagedType.LPWStr)] string pszLocalId, IntPtr pContext, IntPtr ppDeviceProxy);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDCreateDeviceProxyAdvanced' -Namespace Win32 -PassThru
# $api::WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
#uselib "wsdapi.dll"
#func global WSDCreateDeviceProxyAdvanced "WSDCreateDeviceProxyAdvanced" sptr, sptr, sptr, sptr, sptr
; WSDCreateDeviceProxyAdvanced pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy   ; 戻り値は stat
; pszDeviceId : LPCWSTR -> "sptr"
; pDeviceAddress : IWSDAddress* -> "sptr"
; pszLocalId : LPCWSTR -> "sptr"
; pContext : IWSDXMLContext* -> "sptr"
; ppDeviceProxy : IWSDDeviceProxy** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "wsdapi.dll"
#cfunc global WSDCreateDeviceProxyAdvanced "WSDCreateDeviceProxyAdvanced" wstr, sptr, wstr, sptr, sptr
; res = WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
; pszDeviceId : LPCWSTR -> "wstr"
; pDeviceAddress : IWSDAddress* -> "sptr"
; pszLocalId : LPCWSTR -> "wstr"
; pContext : IWSDXMLContext* -> "sptr"
; ppDeviceProxy : IWSDDeviceProxy** out -> "sptr"
; HRESULT WSDCreateDeviceProxyAdvanced(LPCWSTR pszDeviceId, IWSDAddress* pDeviceAddress, LPCWSTR pszLocalId, IWSDXMLContext* pContext, IWSDDeviceProxy** ppDeviceProxy)
#uselib "wsdapi.dll"
#cfunc global WSDCreateDeviceProxyAdvanced "WSDCreateDeviceProxyAdvanced" wstr, intptr, wstr, intptr, intptr
; res = WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
; pszDeviceId : LPCWSTR -> "wstr"
; pDeviceAddress : IWSDAddress* -> "intptr"
; pszLocalId : LPCWSTR -> "wstr"
; pContext : IWSDXMLContext* -> "intptr"
; ppDeviceProxy : IWSDDeviceProxy** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wsdapi = windows.NewLazySystemDLL("wsdapi.dll")
	procWSDCreateDeviceProxyAdvanced = wsdapi.NewProc("WSDCreateDeviceProxyAdvanced")
)

// pszDeviceId (LPCWSTR), pDeviceAddress (IWSDAddress*), pszLocalId (LPCWSTR), pContext (IWSDXMLContext*), ppDeviceProxy (IWSDDeviceProxy** out)
r1, _, err := procWSDCreateDeviceProxyAdvanced.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDeviceId))),
	uintptr(pDeviceAddress),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszLocalId))),
	uintptr(pContext),
	uintptr(ppDeviceProxy),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WSDCreateDeviceProxyAdvanced(
  pszDeviceId: PWideChar;   // LPCWSTR
  pDeviceAddress: Pointer;   // IWSDAddress*
  pszLocalId: PWideChar;   // LPCWSTR
  pContext: Pointer;   // IWSDXMLContext*
  ppDeviceProxy: Pointer   // IWSDDeviceProxy** out
): Integer; stdcall;
  external 'wsdapi.dll' name 'WSDCreateDeviceProxyAdvanced';
result := DllCall("wsdapi\WSDCreateDeviceProxyAdvanced"
    , "WStr", pszDeviceId   ; LPCWSTR
    , "Ptr", pDeviceAddress   ; IWSDAddress*
    , "WStr", pszLocalId   ; LPCWSTR
    , "Ptr", pContext   ; IWSDXMLContext*
    , "Ptr", ppDeviceProxy   ; IWSDDeviceProxy** out
    , "Int")   ; return: HRESULT
●WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy) = DLL("wsdapi.dll", "int WSDCreateDeviceProxyAdvanced(char*, void*, char*, void*, void*)")
# 呼び出し: WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
# pszDeviceId : LPCWSTR -> "char*"
# pDeviceAddress : IWSDAddress* -> "void*"
# pszLocalId : LPCWSTR -> "char*"
# pContext : IWSDXMLContext* -> "void*"
# ppDeviceProxy : IWSDDeviceProxy** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。