Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › NetConfigGetAll

NetConfigGetAll

関数
指定コンポーネントの全構成パラメータをまとめて取得する。
DLLNETAPI32.dll呼出規約winapi

シグネチャ

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

DWORD NetConfigGetAll(
    LPCWSTR server,
    LPCWSTR component,
    BYTE** bufptr
);

パラメーター

名前方向
serverLPCWSTRin
componentLPCWSTRin
bufptrBYTE**inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

NetConfigGetAll = ctypes.windll.netapi32.NetConfigGetAll
NetConfigGetAll.restype = wintypes.DWORD
NetConfigGetAll.argtypes = [
    wintypes.LPCWSTR,  # server : LPCWSTR
    wintypes.LPCWSTR,  # component : LPCWSTR
    ctypes.c_void_p,  # bufptr : BYTE** in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetConfigGetAll = netapi32.NewProc("NetConfigGetAll")
)

// server (LPCWSTR), component (LPCWSTR), bufptr (BYTE** in/out)
r1, _, err := procNetConfigGetAll.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(server))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(component))),
	uintptr(bufptr),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function NetConfigGetAll(
  server: PWideChar;   // LPCWSTR
  component: PWideChar;   // LPCWSTR
  bufptr: Pointer   // BYTE** in/out
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetConfigGetAll';
result := DllCall("NETAPI32\NetConfigGetAll"
    , "WStr", server   ; LPCWSTR
    , "WStr", component   ; LPCWSTR
    , "Ptr", bufptr   ; BYTE** in/out
    , "UInt")   ; return: DWORD
●NetConfigGetAll(server, component, bufptr) = DLL("NETAPI32.dll", "dword NetConfigGetAll(char*, char*, void*)")
# 呼び出し: NetConfigGetAll(server, component, bufptr)
# server : LPCWSTR -> "char*"
# component : LPCWSTR -> "char*"
# bufptr : BYTE** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。