ホーム › Devices.WebServicesOnDevices › WSDCreateDeviceProxy
WSDCreateDeviceProxy
関数リモートWSDデバイスを操作するデバイスプロキシを作成する。
シグネチャ
// wsdapi.dll
#include <windows.h>
HRESULT WSDCreateDeviceProxy(
LPCWSTR pszDeviceId,
LPCWSTR pszLocalId,
IWSDXMLContext* pContext,
IWSDDeviceProxy** ppDeviceProxy
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszDeviceId | LPCWSTR | in | 接続対象デバイスのID(エンドポイント参照URI)を示すUnicode文字列。 |
| pszLocalId | LPCWSTR | in | このプロキシのローカルエンドポイント識別子を示すUnicode文字列。 |
| pContext | IWSDXMLContext* | in | XML処理に用いるIWSDXMLContextへのポインタ。NULL可で既定を使う。 |
| ppDeviceProxy | IWSDDeviceProxy** | out | 作成したIWSDDeviceProxyオブジェクトを受け取る出力先ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// wsdapi.dll
#include <windows.h>
HRESULT WSDCreateDeviceProxy(
LPCWSTR pszDeviceId,
LPCWSTR pszLocalId,
IWSDXMLContext* pContext,
IWSDDeviceProxy** ppDeviceProxy
);[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern int WSDCreateDeviceProxy(
[MarshalAs(UnmanagedType.LPWStr)] string pszDeviceId, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszLocalId, // LPCWSTR
IntPtr pContext, // IWSDXMLContext*
IntPtr ppDeviceProxy // IWSDDeviceProxy** out
);<DllImport("wsdapi.dll", ExactSpelling:=True)>
Public Shared Function WSDCreateDeviceProxy(
<MarshalAs(UnmanagedType.LPWStr)> pszDeviceId As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszLocalId As String, ' LPCWSTR
pContext As IntPtr, ' IWSDXMLContext*
ppDeviceProxy As IntPtr ' IWSDDeviceProxy** out
) As Integer
End Function' pszDeviceId : LPCWSTR
' pszLocalId : LPCWSTR
' pContext : IWSDXMLContext*
' ppDeviceProxy : IWSDDeviceProxy** out
Declare PtrSafe Function WSDCreateDeviceProxy Lib "wsdapi" ( _
ByVal pszDeviceId 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
WSDCreateDeviceProxy = ctypes.windll.wsdapi.WSDCreateDeviceProxy
WSDCreateDeviceProxy.restype = ctypes.c_int
WSDCreateDeviceProxy.argtypes = [
wintypes.LPCWSTR, # pszDeviceId : LPCWSTR
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')
WSDCreateDeviceProxy = Fiddle::Function.new(
lib['WSDCreateDeviceProxy'],
[
Fiddle::TYPE_VOIDP, # pszDeviceId : LPCWSTR
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 WSDCreateDeviceProxy(
pszDeviceId: *const u16, // LPCWSTR
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 WSDCreateDeviceProxy([MarshalAs(UnmanagedType.LPWStr)] string pszDeviceId, [MarshalAs(UnmanagedType.LPWStr)] string pszLocalId, IntPtr pContext, IntPtr ppDeviceProxy);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDCreateDeviceProxy' -Namespace Win32 -PassThru
# $api::WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy)#uselib "wsdapi.dll"
#func global WSDCreateDeviceProxy "WSDCreateDeviceProxy" sptr, sptr, sptr, sptr
; WSDCreateDeviceProxy pszDeviceId, pszLocalId, pContext, ppDeviceProxy ; 戻り値は stat
; pszDeviceId : LPCWSTR -> "sptr"
; pszLocalId : LPCWSTR -> "sptr"
; pContext : IWSDXMLContext* -> "sptr"
; ppDeviceProxy : IWSDDeviceProxy** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "wsdapi.dll"
#cfunc global WSDCreateDeviceProxy "WSDCreateDeviceProxy" wstr, wstr, sptr, sptr
; res = WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy)
; pszDeviceId : LPCWSTR -> "wstr"
; pszLocalId : LPCWSTR -> "wstr"
; pContext : IWSDXMLContext* -> "sptr"
; ppDeviceProxy : IWSDDeviceProxy** out -> "sptr"; HRESULT WSDCreateDeviceProxy(LPCWSTR pszDeviceId, LPCWSTR pszLocalId, IWSDXMLContext* pContext, IWSDDeviceProxy** ppDeviceProxy)
#uselib "wsdapi.dll"
#cfunc global WSDCreateDeviceProxy "WSDCreateDeviceProxy" wstr, wstr, intptr, intptr
; res = WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy)
; pszDeviceId : LPCWSTR -> "wstr"
; pszLocalId : LPCWSTR -> "wstr"
; pContext : IWSDXMLContext* -> "intptr"
; ppDeviceProxy : IWSDDeviceProxy** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsdapi = windows.NewLazySystemDLL("wsdapi.dll")
procWSDCreateDeviceProxy = wsdapi.NewProc("WSDCreateDeviceProxy")
)
// pszDeviceId (LPCWSTR), pszLocalId (LPCWSTR), pContext (IWSDXMLContext*), ppDeviceProxy (IWSDDeviceProxy** out)
r1, _, err := procWSDCreateDeviceProxy.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDeviceId))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszLocalId))),
uintptr(pContext),
uintptr(ppDeviceProxy),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WSDCreateDeviceProxy(
pszDeviceId: PWideChar; // LPCWSTR
pszLocalId: PWideChar; // LPCWSTR
pContext: Pointer; // IWSDXMLContext*
ppDeviceProxy: Pointer // IWSDDeviceProxy** out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDCreateDeviceProxy';result := DllCall("wsdapi\WSDCreateDeviceProxy"
, "WStr", pszDeviceId ; LPCWSTR
, "WStr", pszLocalId ; LPCWSTR
, "Ptr", pContext ; IWSDXMLContext*
, "Ptr", ppDeviceProxy ; IWSDDeviceProxy** out
, "Int") ; return: HRESULT●WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy) = DLL("wsdapi.dll", "int WSDCreateDeviceProxy(char*, char*, void*, void*)")
# 呼び出し: WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy)
# pszDeviceId : LPCWSTR -> "char*"
# 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 WSDCreateDeviceProxy(
pszDeviceId: [*c]const u16, // LPCWSTR
pszLocalId: [*c]const u16, // LPCWSTR
pContext: ?*anyopaque, // IWSDXMLContext*
ppDeviceProxy: ?*anyopaque // IWSDDeviceProxy** out
) callconv(std.os.windows.WINAPI) i32;proc WSDCreateDeviceProxy(
pszDeviceId: WideCString, # LPCWSTR
pszLocalId: WideCString, # LPCWSTR
pContext: pointer, # IWSDXMLContext*
ppDeviceProxy: pointer # IWSDDeviceProxy** out
): int32 {.importc: "WSDCreateDeviceProxy", stdcall, dynlib: "wsdapi.dll".}pragma(lib, "wsdapi");
extern(Windows)
int WSDCreateDeviceProxy(
const(wchar)* pszDeviceId, // LPCWSTR
const(wchar)* pszLocalId, // LPCWSTR
void* pContext, // IWSDXMLContext*
void* ppDeviceProxy // IWSDDeviceProxy** out
);ccall((:WSDCreateDeviceProxy, "wsdapi.dll"), stdcall, Int32,
(Cwstring, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}),
pszDeviceId, pszLocalId, pContext, ppDeviceProxy)
# pszDeviceId : LPCWSTR -> Cwstring
# pszLocalId : LPCWSTR -> Cwstring
# pContext : IWSDXMLContext* -> Ptr{Cvoid}
# ppDeviceProxy : IWSDDeviceProxy** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WSDCreateDeviceProxy(
const uint16_t* pszDeviceId,
const uint16_t* pszLocalId,
void* pContext,
void* ppDeviceProxy);
]]
local wsdapi = ffi.load("wsdapi")
-- wsdapi.WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy)
-- pszDeviceId : LPCWSTR
-- pszLocalId : LPCWSTR
-- pContext : IWSDXMLContext*
-- ppDeviceProxy : IWSDDeviceProxy** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsdapi.dll');
const WSDCreateDeviceProxy = lib.func('__stdcall', 'WSDCreateDeviceProxy', 'int32_t', ['str16', 'str16', 'void *', 'void *']);
// WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy)
// pszDeviceId : LPCWSTR -> 'str16'
// pszLocalId : LPCWSTR -> 'str16'
// pContext : IWSDXMLContext* -> 'void *'
// ppDeviceProxy : IWSDDeviceProxy** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsdapi.dll", {
WSDCreateDeviceProxy: { parameters: ["buffer", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy)
// pszDeviceId : LPCWSTR -> "buffer"
// pszLocalId : LPCWSTR -> "buffer"
// pContext : IWSDXMLContext* -> "pointer"
// ppDeviceProxy : IWSDDeviceProxy** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WSDCreateDeviceProxy(
const uint16_t* pszDeviceId,
const uint16_t* pszLocalId,
void* pContext,
void* ppDeviceProxy);
C, "wsdapi.dll");
// $ffi->WSDCreateDeviceProxy(pszDeviceId, pszLocalId, pContext, ppDeviceProxy);
// pszDeviceId : LPCWSTR
// 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 WSDCreateDeviceProxy(
WString pszDeviceId, // LPCWSTR
WString pszLocalId, // LPCWSTR
Pointer pContext, // IWSDXMLContext*
Pointer ppDeviceProxy // IWSDDeviceProxy** out
);
}@[Link("wsdapi")]
lib Libwsdapi
fun WSDCreateDeviceProxy = WSDCreateDeviceProxy(
pszDeviceId : UInt16*, # LPCWSTR
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 WSDCreateDeviceProxyNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef WSDCreateDeviceProxyDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final WSDCreateDeviceProxy = DynamicLibrary.open('wsdapi.dll')
.lookupFunction<WSDCreateDeviceProxyNative, WSDCreateDeviceProxyDart>('WSDCreateDeviceProxy');
// pszDeviceId : LPCWSTR -> Pointer<Utf16>
// pszLocalId : LPCWSTR -> Pointer<Utf16>
// pContext : IWSDXMLContext* -> Pointer<Void>
// ppDeviceProxy : IWSDDeviceProxy** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WSDCreateDeviceProxy(
pszDeviceId: PWideChar; // LPCWSTR
pszLocalId: PWideChar; // LPCWSTR
pContext: Pointer; // IWSDXMLContext*
ppDeviceProxy: Pointer // IWSDDeviceProxy** out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDCreateDeviceProxy';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WSDCreateDeviceProxy"
c_WSDCreateDeviceProxy :: CWString -> CWString -> Ptr () -> Ptr () -> IO Int32
-- pszDeviceId : LPCWSTR -> CWString
-- pszLocalId : LPCWSTR -> CWString
-- pContext : IWSDXMLContext* -> Ptr ()
-- ppDeviceProxy : IWSDDeviceProxy** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsdcreatedeviceproxy =
foreign "WSDCreateDeviceProxy"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pszDeviceId : LPCWSTR -> (ptr uint16_t) *)
(* 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 ("WSDCreateDeviceProxy" wsdcreate-device-proxy :convention :stdcall) :int32
(psz-device-id (:string :encoding :utf-16le)) ; LPCWSTR
(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 $WSDCreateDeviceProxy = Win32::API::More->new('wsdapi',
'int WSDCreateDeviceProxy(LPCWSTR pszDeviceId, LPCWSTR pszLocalId, LPVOID pContext, LPVOID ppDeviceProxy)');
# my $ret = $WSDCreateDeviceProxy->Call($pszDeviceId, $pszLocalId, $pContext, $ppDeviceProxy);
# pszDeviceId : LPCWSTR -> LPCWSTR
# pszLocalId : LPCWSTR -> LPCWSTR
# pContext : IWSDXMLContext* -> LPVOID
# ppDeviceProxy : IWSDDeviceProxy** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f WSDCreateDeviceProxy2 — 構成パラメータ付きでWSDデバイスプロキシを作成する。