Win32 API 日本語リファレンス
ホームStorage.DistributedFileSystem › NetDfsGetSupportedNamespaceVersion

NetDfsGetSupportedNamespaceVersion

関数
サポートされるDFS名前空間バージョン情報を取得する。
DLLNETAPI32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD NetDfsGetSupportedNamespaceVersion(
    DFS_NAMESPACE_VERSION_ORIGIN Origin,
    LPWSTR pName,   // optional
    DFS_SUPPORTED_NAMESPACE_VERSION_INFO** ppVersionInfo
);

パラメーター

名前方向説明
OriginDFS_NAMESPACE_VERSION_ORIGINinバージョン情報の取得元を示すDFS_NAMESPACE_VERSION_ORIGIN列挙値。サーバーまたはドメインを指定する。
pNameLPWSTRinoptional対象のサーバー名またはドメイン名を示すワイド文字列。
ppVersionInfoDFS_SUPPORTED_NAMESPACE_VERSION_INFO**out取得したサポート対象名前空間バージョン情報を受け取るDFS_SUPPORTED_NAMESPACE_VERSION_INFOへのポインタのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD NetDfsGetSupportedNamespaceVersion(
    DFS_NAMESPACE_VERSION_ORIGIN Origin,
    LPWSTR pName,   // optional
    DFS_SUPPORTED_NAMESPACE_VERSION_INFO** ppVersionInfo
);
[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetDfsGetSupportedNamespaceVersion(
    int Origin,   // DFS_NAMESPACE_VERSION_ORIGIN
    [MarshalAs(UnmanagedType.LPWStr)] string pName,   // LPWSTR optional
    IntPtr ppVersionInfo   // DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
);
<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetDfsGetSupportedNamespaceVersion(
    Origin As Integer,   ' DFS_NAMESPACE_VERSION_ORIGIN
    <MarshalAs(UnmanagedType.LPWStr)> pName As String,   ' LPWSTR optional
    ppVersionInfo As IntPtr   ' DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
) As UInteger
End Function
' Origin : DFS_NAMESPACE_VERSION_ORIGIN
' pName : LPWSTR optional
' ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
Declare PtrSafe Function NetDfsGetSupportedNamespaceVersion Lib "netapi32" ( _
    ByVal Origin As Long, _
    ByVal pName As LongPtr, _
    ByVal ppVersionInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NetDfsGetSupportedNamespaceVersion = ctypes.windll.netapi32.NetDfsGetSupportedNamespaceVersion
NetDfsGetSupportedNamespaceVersion.restype = wintypes.DWORD
NetDfsGetSupportedNamespaceVersion.argtypes = [
    ctypes.c_int,  # Origin : DFS_NAMESPACE_VERSION_ORIGIN
    wintypes.LPCWSTR,  # pName : LPWSTR optional
    ctypes.c_void_p,  # ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetDfsGetSupportedNamespaceVersion = netapi32.NewProc("NetDfsGetSupportedNamespaceVersion")
)

// Origin (DFS_NAMESPACE_VERSION_ORIGIN), pName (LPWSTR optional), ppVersionInfo (DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out)
r1, _, err := procNetDfsGetSupportedNamespaceVersion.Call(
	uintptr(Origin),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pName))),
	uintptr(ppVersionInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function NetDfsGetSupportedNamespaceVersion(
  Origin: Integer;   // DFS_NAMESPACE_VERSION_ORIGIN
  pName: PWideChar;   // LPWSTR optional
  ppVersionInfo: Pointer   // DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetDfsGetSupportedNamespaceVersion';
result := DllCall("NETAPI32\NetDfsGetSupportedNamespaceVersion"
    , "Int", Origin   ; DFS_NAMESPACE_VERSION_ORIGIN
    , "WStr", pName   ; LPWSTR optional
    , "Ptr", ppVersionInfo   ; DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
    , "UInt")   ; return: DWORD
●NetDfsGetSupportedNamespaceVersion(Origin, pName, ppVersionInfo) = DLL("NETAPI32.dll", "dword NetDfsGetSupportedNamespaceVersion(int, char*, void*)")
# 呼び出し: NetDfsGetSupportedNamespaceVersion(Origin, pName, ppVersionInfo)
# Origin : DFS_NAMESPACE_VERSION_ORIGIN -> "int"
# pName : LPWSTR optional -> "char*"
# ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "netapi32" fn NetDfsGetSupportedNamespaceVersion(
    Origin: i32, // DFS_NAMESPACE_VERSION_ORIGIN
    pName: [*c]const u16, // LPWSTR optional
    ppVersionInfo: [*c][*c]DFS_SUPPORTED_NAMESPACE_VERSION_INFO // DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
) callconv(std.os.windows.WINAPI) u32;
proc NetDfsGetSupportedNamespaceVersion(
    Origin: int32,  # DFS_NAMESPACE_VERSION_ORIGIN
    pName: WideCString,  # LPWSTR optional
    ppVersionInfo: ptr DFS_SUPPORTED_NAMESPACE_VERSION_INFO  # DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
): uint32 {.importc: "NetDfsGetSupportedNamespaceVersion", stdcall, dynlib: "NETAPI32.dll".}
pragma(lib, "netapi32");
extern(Windows)
uint NetDfsGetSupportedNamespaceVersion(
    int Origin,   // DFS_NAMESPACE_VERSION_ORIGIN
    const(wchar)* pName,   // LPWSTR optional
    DFS_SUPPORTED_NAMESPACE_VERSION_INFO** ppVersionInfo   // DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
);
ccall((:NetDfsGetSupportedNamespaceVersion, "NETAPI32.dll"), stdcall, UInt32,
      (Int32, Cwstring, Ptr{DFS_SUPPORTED_NAMESPACE_VERSION_INFO}),
      Origin, pName, ppVersionInfo)
# Origin : DFS_NAMESPACE_VERSION_ORIGIN -> Int32
# pName : LPWSTR optional -> Cwstring
# ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> Ptr{DFS_SUPPORTED_NAMESPACE_VERSION_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t NetDfsGetSupportedNamespaceVersion(
    int32_t Origin,
    const uint16_t* pName,
    void* ppVersionInfo);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetDfsGetSupportedNamespaceVersion(Origin, pName, ppVersionInfo)
-- Origin : DFS_NAMESPACE_VERSION_ORIGIN
-- pName : LPWSTR optional
-- ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetDfsGetSupportedNamespaceVersion = lib.func('__stdcall', 'NetDfsGetSupportedNamespaceVersion', 'uint32_t', ['int32_t', 'str16', 'void *']);
// NetDfsGetSupportedNamespaceVersion(Origin, pName, ppVersionInfo)
// Origin : DFS_NAMESPACE_VERSION_ORIGIN -> 'int32_t'
// pName : LPWSTR optional -> 'str16'
// ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("NETAPI32.dll", {
  NetDfsGetSupportedNamespaceVersion: { parameters: ["i32", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.NetDfsGetSupportedNamespaceVersion(Origin, pName, ppVersionInfo)
// Origin : DFS_NAMESPACE_VERSION_ORIGIN -> "i32"
// pName : LPWSTR optional -> "buffer"
// ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t NetDfsGetSupportedNamespaceVersion(
    int32_t Origin,
    const uint16_t* pName,
    void* ppVersionInfo);
C, "NETAPI32.dll");
// $ffi->NetDfsGetSupportedNamespaceVersion(Origin, pName, ppVersionInfo);
// Origin : DFS_NAMESPACE_VERSION_ORIGIN
// pName : LPWSTR optional
// ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** 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 Netapi32 extends StdCallLibrary {
    Netapi32 INSTANCE = Native.load("netapi32", Netapi32.class);
    int NetDfsGetSupportedNamespaceVersion(
        int Origin,   // DFS_NAMESPACE_VERSION_ORIGIN
        WString pName,   // LPWSTR optional
        Pointer ppVersionInfo   // DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
    );
}
@[Link("netapi32")]
lib LibNETAPI32
  fun NetDfsGetSupportedNamespaceVersion = NetDfsGetSupportedNamespaceVersion(
    Origin : Int32,   # DFS_NAMESPACE_VERSION_ORIGIN
    pName : UInt16*,   # LPWSTR optional
    ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO**   # DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef NetDfsGetSupportedNamespaceVersionNative = Uint32 Function(Int32, Pointer<Utf16>, Pointer<Void>);
typedef NetDfsGetSupportedNamespaceVersionDart = int Function(int, Pointer<Utf16>, Pointer<Void>);
final NetDfsGetSupportedNamespaceVersion = DynamicLibrary.open('NETAPI32.dll')
    .lookupFunction<NetDfsGetSupportedNamespaceVersionNative, NetDfsGetSupportedNamespaceVersionDart>('NetDfsGetSupportedNamespaceVersion');
// Origin : DFS_NAMESPACE_VERSION_ORIGIN -> Int32
// pName : LPWSTR optional -> Pointer<Utf16>
// ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function NetDfsGetSupportedNamespaceVersion(
  Origin: Integer;   // DFS_NAMESPACE_VERSION_ORIGIN
  pName: PWideChar;   // LPWSTR optional
  ppVersionInfo: Pointer   // DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetDfsGetSupportedNamespaceVersion';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NetDfsGetSupportedNamespaceVersion"
  c_NetDfsGetSupportedNamespaceVersion :: Int32 -> CWString -> Ptr () -> IO Word32
-- Origin : DFS_NAMESPACE_VERSION_ORIGIN -> Int32
-- pName : LPWSTR optional -> CWString
-- ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let netdfsgetsupportednamespaceversion =
  foreign "NetDfsGetSupportedNamespaceVersion"
    (int32_t @-> (ptr uint16_t) @-> (ptr void) @-> returning uint32_t)
(* Origin : DFS_NAMESPACE_VERSION_ORIGIN -> int32_t *)
(* pName : LPWSTR optional -> (ptr uint16_t) *)
(* ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)

(cffi:defcfun ("NetDfsGetSupportedNamespaceVersion" net-dfs-get-supported-namespace-version :convention :stdcall) :uint32
  (origin :int32)   ; DFS_NAMESPACE_VERSION_ORIGIN
  (p-name (:string :encoding :utf-16le))   ; LPWSTR optional
  (pp-version-info :pointer))   ; DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NetDfsGetSupportedNamespaceVersion = Win32::API::More->new('NETAPI32',
    'DWORD NetDfsGetSupportedNamespaceVersion(int Origin, LPCWSTR pName, LPVOID ppVersionInfo)');
# my $ret = $NetDfsGetSupportedNamespaceVersion->Call($Origin, $pName, $ppVersionInfo);
# Origin : DFS_NAMESPACE_VERSION_ORIGIN -> int
# pName : LPWSTR optional -> LPCWSTR
# ppVersionInfo : DFS_SUPPORTED_NAMESPACE_VERSION_INFO** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型