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

WSDXMLGetValueFromAny

関数
WSDXML要素から指定名前空間と名前の値を取得する。
DLLwsdapi.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WSDXMLGetValueFromAny(
    LPCWSTR pszNamespace,
    LPCWSTR pszName,
    WSDXML_ELEMENT* pAny,
    LPCWSTR* ppszValue
);

パラメーター

名前方向
pszNamespaceLPCWSTRin
pszNameLPCWSTRin
pAnyWSDXML_ELEMENT*inout
ppszValueLPCWSTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WSDXMLGetValueFromAny(
    LPCWSTR pszNamespace,
    LPCWSTR pszName,
    WSDXML_ELEMENT* pAny,
    LPCWSTR* ppszValue
);
[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern int WSDXMLGetValueFromAny(
    [MarshalAs(UnmanagedType.LPWStr)] string pszNamespace,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszName,   // LPCWSTR
    IntPtr pAny,   // WSDXML_ELEMENT* in/out
    IntPtr ppszValue   // LPCWSTR* out
);
<DllImport("wsdapi.dll", ExactSpelling:=True)>
Public Shared Function WSDXMLGetValueFromAny(
    <MarshalAs(UnmanagedType.LPWStr)> pszNamespace As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszName As String,   ' LPCWSTR
    pAny As IntPtr,   ' WSDXML_ELEMENT* in/out
    ppszValue As IntPtr   ' LPCWSTR* out
) As Integer
End Function
' pszNamespace : LPCWSTR
' pszName : LPCWSTR
' pAny : WSDXML_ELEMENT* in/out
' ppszValue : LPCWSTR* out
Declare PtrSafe Function WSDXMLGetValueFromAny Lib "wsdapi" ( _
    ByVal pszNamespace As LongPtr, _
    ByVal pszName As LongPtr, _
    ByVal pAny As LongPtr, _
    ByVal ppszValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WSDXMLGetValueFromAny = ctypes.windll.wsdapi.WSDXMLGetValueFromAny
WSDXMLGetValueFromAny.restype = ctypes.c_int
WSDXMLGetValueFromAny.argtypes = [
    wintypes.LPCWSTR,  # pszNamespace : LPCWSTR
    wintypes.LPCWSTR,  # pszName : LPCWSTR
    ctypes.c_void_p,  # pAny : WSDXML_ELEMENT* in/out
    ctypes.c_void_p,  # ppszValue : LPCWSTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wsdapi.dll')
WSDXMLGetValueFromAny = Fiddle::Function.new(
  lib['WSDXMLGetValueFromAny'],
  [
    Fiddle::TYPE_VOIDP,  # pszNamespace : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pAny : WSDXML_ELEMENT* in/out
    Fiddle::TYPE_VOIDP,  # ppszValue : LPCWSTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wsdapi")]
extern "system" {
    fn WSDXMLGetValueFromAny(
        pszNamespace: *const u16,  // LPCWSTR
        pszName: *const u16,  // LPCWSTR
        pAny: *mut WSDXML_ELEMENT,  // WSDXML_ELEMENT* in/out
        ppszValue: *const *const u16  // LPCWSTR* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wsdapi.dll")]
public static extern int WSDXMLGetValueFromAny([MarshalAs(UnmanagedType.LPWStr)] string pszNamespace, [MarshalAs(UnmanagedType.LPWStr)] string pszName, IntPtr pAny, IntPtr ppszValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDXMLGetValueFromAny' -Namespace Win32 -PassThru
# $api::WSDXMLGetValueFromAny(pszNamespace, pszName, pAny, ppszValue)
#uselib "wsdapi.dll"
#func global WSDXMLGetValueFromAny "WSDXMLGetValueFromAny" sptr, sptr, sptr, sptr
; WSDXMLGetValueFromAny pszNamespace, pszName, varptr(pAny), varptr(ppszValue)   ; 戻り値は stat
; pszNamespace : LPCWSTR -> "sptr"
; pszName : LPCWSTR -> "sptr"
; pAny : WSDXML_ELEMENT* in/out -> "sptr"
; ppszValue : LPCWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wsdapi.dll"
#cfunc global WSDXMLGetValueFromAny "WSDXMLGetValueFromAny" wstr, wstr, var, var
; res = WSDXMLGetValueFromAny(pszNamespace, pszName, pAny, ppszValue)
; pszNamespace : LPCWSTR -> "wstr"
; pszName : LPCWSTR -> "wstr"
; pAny : WSDXML_ELEMENT* in/out -> "var"
; ppszValue : LPCWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WSDXMLGetValueFromAny(LPCWSTR pszNamespace, LPCWSTR pszName, WSDXML_ELEMENT* pAny, LPCWSTR* ppszValue)
#uselib "wsdapi.dll"
#cfunc global WSDXMLGetValueFromAny "WSDXMLGetValueFromAny" wstr, wstr, var, var
; res = WSDXMLGetValueFromAny(pszNamespace, pszName, pAny, ppszValue)
; pszNamespace : LPCWSTR -> "wstr"
; pszName : LPCWSTR -> "wstr"
; pAny : WSDXML_ELEMENT* in/out -> "var"
; ppszValue : LPCWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wsdapi = windows.NewLazySystemDLL("wsdapi.dll")
	procWSDXMLGetValueFromAny = wsdapi.NewProc("WSDXMLGetValueFromAny")
)

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