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接続対象デバイスのID(エンドポイント参照URI)を示すUnicode文字列。
pDeviceAddressIWSDAddress*inデバイスのトランスポートアドレスを示すIWSDAddressへのポインタ。
pszLocalIdLPCWSTRinこのプロキシのローカルエンドポイント識別子を示すUnicode文字列。
pContextIWSDXMLContext*inXML処理に用いるIWSDXMLContextへのポインタ。NULL可で既定を使う。
ppDeviceProxyIWSDDeviceProxy**out作成したIWSDDeviceProxyオブジェクトを受け取る出力先ポインタ。

戻り値の型: 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)。
const std = @import("std");

extern "wsdapi" fn WSDCreateDeviceProxyAdvanced(
    pszDeviceId: [*c]const u16, // LPCWSTR
    pDeviceAddress: ?*anyopaque, // IWSDAddress*
    pszLocalId: [*c]const u16, // LPCWSTR
    pContext: ?*anyopaque, // IWSDXMLContext*
    ppDeviceProxy: ?*anyopaque // IWSDDeviceProxy** out
) callconv(std.os.windows.WINAPI) i32;
proc WSDCreateDeviceProxyAdvanced(
    pszDeviceId: WideCString,  # LPCWSTR
    pDeviceAddress: pointer,  # IWSDAddress*
    pszLocalId: WideCString,  # LPCWSTR
    pContext: pointer,  # IWSDXMLContext*
    ppDeviceProxy: pointer  # IWSDDeviceProxy** out
): int32 {.importc: "WSDCreateDeviceProxyAdvanced", stdcall, dynlib: "wsdapi.dll".}
pragma(lib, "wsdapi");
extern(Windows)
int WSDCreateDeviceProxyAdvanced(
    const(wchar)* pszDeviceId,   // LPCWSTR
    void* pDeviceAddress,   // IWSDAddress*
    const(wchar)* pszLocalId,   // LPCWSTR
    void* pContext,   // IWSDXMLContext*
    void* ppDeviceProxy   // IWSDDeviceProxy** out
);
ccall((:WSDCreateDeviceProxyAdvanced, "wsdapi.dll"), stdcall, Int32,
      (Cwstring, Ptr{Cvoid}, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}),
      pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
# pszDeviceId : LPCWSTR -> Cwstring
# pDeviceAddress : IWSDAddress* -> Ptr{Cvoid}
# pszLocalId : LPCWSTR -> Cwstring
# pContext : IWSDXMLContext* -> Ptr{Cvoid}
# ppDeviceProxy : IWSDDeviceProxy** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WSDCreateDeviceProxyAdvanced(
    const uint16_t* pszDeviceId,
    void* pDeviceAddress,
    const uint16_t* pszLocalId,
    void* pContext,
    void* ppDeviceProxy);
]]
local wsdapi = ffi.load("wsdapi")
-- wsdapi.WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
-- pszDeviceId : LPCWSTR
-- pDeviceAddress : IWSDAddress*
-- pszLocalId : LPCWSTR
-- pContext : IWSDXMLContext*
-- ppDeviceProxy : IWSDDeviceProxy** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wsdapi.dll');
const WSDCreateDeviceProxyAdvanced = lib.func('__stdcall', 'WSDCreateDeviceProxyAdvanced', 'int32_t', ['str16', 'void *', 'str16', 'void *', 'void *']);
// WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
// pszDeviceId : LPCWSTR -> 'str16'
// pDeviceAddress : IWSDAddress* -> 'void *'
// pszLocalId : LPCWSTR -> 'str16'
// pContext : IWSDXMLContext* -> 'void *'
// ppDeviceProxy : IWSDDeviceProxy** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wsdapi.dll", {
  WSDCreateDeviceProxyAdvanced: { parameters: ["buffer", "pointer", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy)
// pszDeviceId : LPCWSTR -> "buffer"
// pDeviceAddress : IWSDAddress* -> "pointer"
// pszLocalId : LPCWSTR -> "buffer"
// pContext : IWSDXMLContext* -> "pointer"
// ppDeviceProxy : IWSDDeviceProxy** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WSDCreateDeviceProxyAdvanced(
    const uint16_t* pszDeviceId,
    void* pDeviceAddress,
    const uint16_t* pszLocalId,
    void* pContext,
    void* ppDeviceProxy);
C, "wsdapi.dll");
// $ffi->WSDCreateDeviceProxyAdvanced(pszDeviceId, pDeviceAddress, pszLocalId, pContext, ppDeviceProxy);
// pszDeviceId : LPCWSTR
// pDeviceAddress : IWSDAddress*
// pszLocalId : LPCWSTR
// pContext : IWSDXMLContext*
// ppDeviceProxy : IWSDDeviceProxy** out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Wsdapi extends StdCallLibrary {
    Wsdapi INSTANCE = Native.load("wsdapi", Wsdapi.class);
    int WSDCreateDeviceProxyAdvanced(
        WString pszDeviceId,   // LPCWSTR
        Pointer pDeviceAddress,   // IWSDAddress*
        WString pszLocalId,   // LPCWSTR
        Pointer pContext,   // IWSDXMLContext*
        Pointer ppDeviceProxy   // IWSDDeviceProxy** out
    );
}
@[Link("wsdapi")]
lib Libwsdapi
  fun WSDCreateDeviceProxyAdvanced = WSDCreateDeviceProxyAdvanced(
    pszDeviceId : UInt16*,   # LPCWSTR
    pDeviceAddress : Void*,   # IWSDAddress*
    pszLocalId : UInt16*,   # LPCWSTR
    pContext : Void*,   # IWSDXMLContext*
    ppDeviceProxy : Void*   # IWSDDeviceProxy** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WSDCreateDeviceProxyAdvancedNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef WSDCreateDeviceProxyAdvancedDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final WSDCreateDeviceProxyAdvanced = DynamicLibrary.open('wsdapi.dll')
    .lookupFunction<WSDCreateDeviceProxyAdvancedNative, WSDCreateDeviceProxyAdvancedDart>('WSDCreateDeviceProxyAdvanced');
// pszDeviceId : LPCWSTR -> Pointer<Utf16>
// pDeviceAddress : IWSDAddress* -> Pointer<Void>
// pszLocalId : LPCWSTR -> Pointer<Utf16>
// pContext : IWSDXMLContext* -> Pointer<Void>
// ppDeviceProxy : IWSDDeviceProxy** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WSDCreateDeviceProxyAdvanced"
  c_WSDCreateDeviceProxyAdvanced :: CWString -> Ptr () -> CWString -> Ptr () -> Ptr () -> IO Int32
-- pszDeviceId : LPCWSTR -> CWString
-- pDeviceAddress : IWSDAddress* -> Ptr ()
-- pszLocalId : LPCWSTR -> CWString
-- pContext : IWSDXMLContext* -> Ptr ()
-- ppDeviceProxy : IWSDDeviceProxy** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wsdcreatedeviceproxyadvanced =
  foreign "WSDCreateDeviceProxyAdvanced"
    ((ptr uint16_t) @-> (ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pszDeviceId : LPCWSTR -> (ptr uint16_t) *)
(* pDeviceAddress : IWSDAddress* -> (ptr void) *)
(* pszLocalId : LPCWSTR -> (ptr uint16_t) *)
(* pContext : IWSDXMLContext* -> (ptr void) *)
(* ppDeviceProxy : IWSDDeviceProxy** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wsdapi (t "wsdapi.dll"))
(cffi:use-foreign-library wsdapi)

(cffi:defcfun ("WSDCreateDeviceProxyAdvanced" wsdcreate-device-proxy-advanced :convention :stdcall) :int32
  (psz-device-id (:string :encoding :utf-16le))   ; LPCWSTR
  (p-device-address :pointer)   ; IWSDAddress*
  (psz-local-id (:string :encoding :utf-16le))   ; LPCWSTR
  (p-context :pointer)   ; IWSDXMLContext*
  (pp-device-proxy :pointer))   ; IWSDDeviceProxy** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WSDCreateDeviceProxyAdvanced = Win32::API::More->new('wsdapi',
    'int WSDCreateDeviceProxyAdvanced(LPCWSTR pszDeviceId, LPVOID pDeviceAddress, LPCWSTR pszLocalId, LPVOID pContext, LPVOID ppDeviceProxy)');
# my $ret = $WSDCreateDeviceProxyAdvanced->Call($pszDeviceId, $pDeviceAddress, $pszLocalId, $pContext, $ppDeviceProxy);
# pszDeviceId : LPCWSTR -> LPCWSTR
# pDeviceAddress : IWSDAddress* -> LPVOID
# pszLocalId : LPCWSTR -> LPCWSTR
# pContext : IWSDXMLContext* -> LPVOID
# ppDeviceProxy : IWSDDeviceProxy** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型