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