ホーム › System.HostComputeNetwork › HcnQueryNamespaceProperties
HcnQueryNamespaceProperties
関数名前空間のプロパティを照会して取得する。
シグネチャ
// computenetwork.dll
#include <windows.h>
HRESULT HcnQueryNamespaceProperties(
void* Namespace,
LPCWSTR Query,
LPWSTR* Properties,
LPWSTR* ErrorRecord // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Namespace | void* | in |
| Query | LPCWSTR | in |
| Properties | LPWSTR* | out |
| ErrorRecord | LPWSTR* | outoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// computenetwork.dll
#include <windows.h>
HRESULT HcnQueryNamespaceProperties(
void* Namespace,
LPCWSTR Query,
LPWSTR* Properties,
LPWSTR* ErrorRecord // optional
);[DllImport("computenetwork.dll", ExactSpelling = true)]
static extern int HcnQueryNamespaceProperties(
IntPtr Namespace, // void*
[MarshalAs(UnmanagedType.LPWStr)] string Query, // LPCWSTR
IntPtr Properties, // LPWSTR* out
IntPtr ErrorRecord // LPWSTR* optional, out
);<DllImport("computenetwork.dll", ExactSpelling:=True)>
Public Shared Function HcnQueryNamespaceProperties(
[Namespace] As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> Query As String, ' LPCWSTR
Properties As IntPtr, ' LPWSTR* out
ErrorRecord As IntPtr ' LPWSTR* optional, out
) As Integer
End Function' Namespace : void*
' Query : LPCWSTR
' Properties : LPWSTR* out
' ErrorRecord : LPWSTR* optional, out
Declare PtrSafe Function HcnQueryNamespaceProperties Lib "computenetwork" ( _
ByVal Namespace As LongPtr, _
ByVal Query As LongPtr, _
ByVal Properties As LongPtr, _
ByVal ErrorRecord As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcnQueryNamespaceProperties = ctypes.windll.computenetwork.HcnQueryNamespaceProperties
HcnQueryNamespaceProperties.restype = ctypes.c_int
HcnQueryNamespaceProperties.argtypes = [
ctypes.POINTER(None), # Namespace : void*
wintypes.LPCWSTR, # Query : LPCWSTR
ctypes.c_void_p, # Properties : LPWSTR* out
ctypes.c_void_p, # ErrorRecord : LPWSTR* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computenetwork.dll')
HcnQueryNamespaceProperties = Fiddle::Function.new(
lib['HcnQueryNamespaceProperties'],
[
Fiddle::TYPE_VOIDP, # Namespace : void*
Fiddle::TYPE_VOIDP, # Query : LPCWSTR
Fiddle::TYPE_VOIDP, # Properties : LPWSTR* out
Fiddle::TYPE_VOIDP, # ErrorRecord : LPWSTR* optional, out
],
Fiddle::TYPE_INT)#[link(name = "computenetwork")]
extern "system" {
fn HcnQueryNamespaceProperties(
Namespace: *mut (), // void*
Query: *const u16, // LPCWSTR
Properties: *mut *mut u16, // LPWSTR* out
ErrorRecord: *mut *mut u16 // LPWSTR* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computenetwork.dll")]
public static extern int HcnQueryNamespaceProperties(IntPtr Namespace, [MarshalAs(UnmanagedType.LPWStr)] string Query, IntPtr Properties, IntPtr ErrorRecord);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computenetwork_HcnQueryNamespaceProperties' -Namespace Win32 -PassThru
# $api::HcnQueryNamespaceProperties(Namespace, Query, Properties, ErrorRecord)#uselib "computenetwork.dll"
#func global HcnQueryNamespaceProperties "HcnQueryNamespaceProperties" sptr, sptr, sptr, sptr
; HcnQueryNamespaceProperties Namespace, Query, varptr(Properties), varptr(ErrorRecord) ; 戻り値は stat
; Namespace : void* -> "sptr"
; Query : LPCWSTR -> "sptr"
; Properties : LPWSTR* out -> "sptr"
; ErrorRecord : LPWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "computenetwork.dll" #cfunc global HcnQueryNamespaceProperties "HcnQueryNamespaceProperties" sptr, wstr, var, var ; res = HcnQueryNamespaceProperties(Namespace, Query, Properties, ErrorRecord) ; Namespace : void* -> "sptr" ; Query : LPCWSTR -> "wstr" ; Properties : LPWSTR* out -> "var" ; ErrorRecord : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "computenetwork.dll" #cfunc global HcnQueryNamespaceProperties "HcnQueryNamespaceProperties" sptr, wstr, sptr, sptr ; res = HcnQueryNamespaceProperties(Namespace, Query, varptr(Properties), varptr(ErrorRecord)) ; Namespace : void* -> "sptr" ; Query : LPCWSTR -> "wstr" ; Properties : LPWSTR* out -> "sptr" ; ErrorRecord : LPWSTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT HcnQueryNamespaceProperties(void* Namespace, LPCWSTR Query, LPWSTR* Properties, LPWSTR* ErrorRecord) #uselib "computenetwork.dll" #cfunc global HcnQueryNamespaceProperties "HcnQueryNamespaceProperties" intptr, wstr, var, var ; res = HcnQueryNamespaceProperties(Namespace, Query, Properties, ErrorRecord) ; Namespace : void* -> "intptr" ; Query : LPCWSTR -> "wstr" ; Properties : LPWSTR* out -> "var" ; ErrorRecord : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT HcnQueryNamespaceProperties(void* Namespace, LPCWSTR Query, LPWSTR* Properties, LPWSTR* ErrorRecord) #uselib "computenetwork.dll" #cfunc global HcnQueryNamespaceProperties "HcnQueryNamespaceProperties" intptr, wstr, intptr, intptr ; res = HcnQueryNamespaceProperties(Namespace, Query, varptr(Properties), varptr(ErrorRecord)) ; Namespace : void* -> "intptr" ; Query : LPCWSTR -> "wstr" ; Properties : LPWSTR* out -> "intptr" ; ErrorRecord : LPWSTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computenetwork = windows.NewLazySystemDLL("computenetwork.dll")
procHcnQueryNamespaceProperties = computenetwork.NewProc("HcnQueryNamespaceProperties")
)
// Namespace (void*), Query (LPCWSTR), Properties (LPWSTR* out), ErrorRecord (LPWSTR* optional, out)
r1, _, err := procHcnQueryNamespaceProperties.Call(
uintptr(Namespace),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Query))),
uintptr(Properties),
uintptr(ErrorRecord),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcnQueryNamespaceProperties(
Namespace: Pointer; // void*
Query: PWideChar; // LPCWSTR
Properties: PPWideChar; // LPWSTR* out
ErrorRecord: PPWideChar // LPWSTR* optional, out
): Integer; stdcall;
external 'computenetwork.dll' name 'HcnQueryNamespaceProperties';result := DllCall("computenetwork\HcnQueryNamespaceProperties"
, "Ptr", Namespace ; void*
, "WStr", Query ; LPCWSTR
, "Ptr", Properties ; LPWSTR* out
, "Ptr", ErrorRecord ; LPWSTR* optional, out
, "Int") ; return: HRESULT●HcnQueryNamespaceProperties(Namespace, Query, Properties, ErrorRecord) = DLL("computenetwork.dll", "int HcnQueryNamespaceProperties(void*, char*, void*, void*)")
# 呼び出し: HcnQueryNamespaceProperties(Namespace, Query, Properties, ErrorRecord)
# Namespace : void* -> "void*"
# Query : LPCWSTR -> "char*"
# Properties : LPWSTR* out -> "void*"
# ErrorRecord : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。