ホーム › Devices.WebServicesOnDevices › WSDCreateDeviceProxy
WSDCreateDeviceProxy
関数リモートWSDデバイスを操作するデバイスプロキシを作成する。
シグネチャ
// wsdapi.dll
#include <windows.h>
HRESULT WSDCreateDeviceProxy(
LPCWSTR pszDeviceId,
LPCWSTR pszLocalId,
IWSDXMLContext* pContext,
IWSDDeviceProxy** ppDeviceProxy
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszDeviceId | LPCWSTR | in |
| pszLocalId | LPCWSTR | in |
| pContext | IWSDXMLContext* | in |
| ppDeviceProxy | IWSDDeviceProxy** | out |
戻り値の型: 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)。