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

NetConfigGet

関数
サーバーから指定した構成パラメータの値を取得する。
DLLNETAPI32.dll呼出規約winapi

シグネチャ

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

DWORD NetConfigGet(
    LPCWSTR server,
    LPCWSTR component,
    LPCWSTR parameter,
    BYTE** bufptr
);

パラメーター

名前方向説明
serverLPCWSTRin未定義(TBD)。
componentLPCWSTRin未定義(TBD)。
parameterLPCWSTRin未定義(TBD)。
bufptrBYTE**inout未定義(TBD)。

戻り値の型: DWORD

公式ドキュメント

NetConfigGet 関数は廃止されています。これは 16 ビット版の Windows との互換性のために含まれています。その他のアプリケーションはレジストリを使用してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

DWORD NetConfigGet(
    LPCWSTR server,
    LPCWSTR component,
    LPCWSTR parameter,
    BYTE** bufptr
);
[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetConfigGet(
    [MarshalAs(UnmanagedType.LPWStr)] string server,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string component,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string parameter,   // LPCWSTR
    IntPtr bufptr   // BYTE** in/out
);
<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetConfigGet(
    <MarshalAs(UnmanagedType.LPWStr)> server As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> component As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> parameter As String,   ' LPCWSTR
    bufptr As IntPtr   ' BYTE** in/out
) As UInteger
End Function
' server : LPCWSTR
' component : LPCWSTR
' parameter : LPCWSTR
' bufptr : BYTE** in/out
Declare PtrSafe Function NetConfigGet Lib "netapi32" ( _
    ByVal server As LongPtr, _
    ByVal component As LongPtr, _
    ByVal parameter 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

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

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetConfigGet = netapi32.NewProc("NetConfigGet")
)

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

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

typedef NetConfigGetNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint8>);
typedef NetConfigGetDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint8>);
final NetConfigGet = DynamicLibrary.open('NETAPI32.dll')
    .lookupFunction<NetConfigGetNative, NetConfigGetDart>('NetConfigGet');
// server : LPCWSTR -> Pointer<Utf16>
// component : LPCWSTR -> Pointer<Utf16>
// parameter : LPCWSTR -> Pointer<Utf16>
// bufptr : BYTE** in/out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function NetConfigGet(
  server: PWideChar;   // LPCWSTR
  component: PWideChar;   // LPCWSTR
  parameter: PWideChar;   // LPCWSTR
  bufptr: Pointer   // BYTE** in/out
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetConfigGet';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NetConfigGet"
  c_NetConfigGet :: CWString -> CWString -> CWString -> Ptr Word8 -> IO Word32
-- server : LPCWSTR -> CWString
-- component : LPCWSTR -> CWString
-- parameter : LPCWSTR -> CWString
-- bufptr : BYTE** in/out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let netconfigget =
  foreign "NetConfigGet"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint8_t) @-> returning uint32_t)
(* server : LPCWSTR -> (ptr uint16_t) *)
(* component : LPCWSTR -> (ptr uint16_t) *)
(* parameter : LPCWSTR -> (ptr uint16_t) *)
(* bufptr : BYTE** in/out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)

(cffi:defcfun ("NetConfigGet" net-config-get :convention :stdcall) :uint32
  (server (:string :encoding :utf-16le))   ; LPCWSTR
  (component (:string :encoding :utf-16le))   ; LPCWSTR
  (parameter (:string :encoding :utf-16le))   ; LPCWSTR
  (bufptr :pointer))   ; BYTE** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NetConfigGet = Win32::API::More->new('NETAPI32',
    'DWORD NetConfigGet(LPCWSTR server, LPCWSTR component, LPCWSTR parameter, LPVOID bufptr)');
# my $ret = $NetConfigGet->Call($server, $component, $parameter, $bufptr);
# server : LPCWSTR -> LPCWSTR
# component : LPCWSTR -> LPCWSTR
# parameter : LPCWSTR -> LPCWSTR
# bufptr : BYTE** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。