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

PreprocessCommand

関数
netshコマンドの引数を解析しタグを前処理する。
DLLNETSH.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD PreprocessCommand(
    HANDLE hModule,   // optional
    LPWSTR* ppwcArguments,
    DWORD dwCurrentIndex,
    DWORD dwArgCount,
    TAG_TYPE* pttTags,   // optional
    DWORD dwTagCount,
    DWORD dwMinArgs,
    DWORD dwMaxArgs,
    DWORD* pdwTagType   // optional
);

パラメーター

名前方向
hModuleHANDLEinoptional
ppwcArgumentsLPWSTR*inout
dwCurrentIndexDWORDin
dwArgCountDWORDin
pttTagsTAG_TYPE*inoutoptional
dwTagCountDWORDin
dwMinArgsDWORDin
dwMaxArgsDWORDin
pdwTagTypeDWORD*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PreprocessCommand(
    HANDLE hModule,   // optional
    LPWSTR* ppwcArguments,
    DWORD dwCurrentIndex,
    DWORD dwArgCount,
    TAG_TYPE* pttTags,   // optional
    DWORD dwTagCount,
    DWORD dwMinArgs,
    DWORD dwMaxArgs,
    DWORD* pdwTagType   // optional
);
[DllImport("NETSH.dll", ExactSpelling = true)]
static extern uint PreprocessCommand(
    IntPtr hModule,   // HANDLE optional
    IntPtr ppwcArguments,   // LPWSTR* in/out
    uint dwCurrentIndex,   // DWORD
    uint dwArgCount,   // DWORD
    IntPtr pttTags,   // TAG_TYPE* optional, in/out
    uint dwTagCount,   // DWORD
    uint dwMinArgs,   // DWORD
    uint dwMaxArgs,   // DWORD
    IntPtr pdwTagType   // DWORD* optional, out
);
<DllImport("NETSH.dll", ExactSpelling:=True)>
Public Shared Function PreprocessCommand(
    hModule As IntPtr,   ' HANDLE optional
    ppwcArguments As IntPtr,   ' LPWSTR* in/out
    dwCurrentIndex As UInteger,   ' DWORD
    dwArgCount As UInteger,   ' DWORD
    pttTags As IntPtr,   ' TAG_TYPE* optional, in/out
    dwTagCount As UInteger,   ' DWORD
    dwMinArgs As UInteger,   ' DWORD
    dwMaxArgs As UInteger,   ' DWORD
    pdwTagType As IntPtr   ' DWORD* optional, out
) As UInteger
End Function
' hModule : HANDLE optional
' ppwcArguments : LPWSTR* in/out
' dwCurrentIndex : DWORD
' dwArgCount : DWORD
' pttTags : TAG_TYPE* optional, in/out
' dwTagCount : DWORD
' dwMinArgs : DWORD
' dwMaxArgs : DWORD
' pdwTagType : DWORD* optional, out
Declare PtrSafe Function PreprocessCommand Lib "netsh" ( _
    ByVal hModule As LongPtr, _
    ByVal ppwcArguments As LongPtr, _
    ByVal dwCurrentIndex As Long, _
    ByVal dwArgCount As Long, _
    ByVal pttTags As LongPtr, _
    ByVal dwTagCount As Long, _
    ByVal dwMinArgs As Long, _
    ByVal dwMaxArgs As Long, _
    ByVal pdwTagType As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PreprocessCommand = ctypes.windll.netsh.PreprocessCommand
PreprocessCommand.restype = wintypes.DWORD
PreprocessCommand.argtypes = [
    wintypes.HANDLE,  # hModule : HANDLE optional
    ctypes.c_void_p,  # ppwcArguments : LPWSTR* in/out
    wintypes.DWORD,  # dwCurrentIndex : DWORD
    wintypes.DWORD,  # dwArgCount : DWORD
    ctypes.c_void_p,  # pttTags : TAG_TYPE* optional, in/out
    wintypes.DWORD,  # dwTagCount : DWORD
    wintypes.DWORD,  # dwMinArgs : DWORD
    wintypes.DWORD,  # dwMaxArgs : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pdwTagType : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NETSH.dll')
PreprocessCommand = Fiddle::Function.new(
  lib['PreprocessCommand'],
  [
    Fiddle::TYPE_VOIDP,  # hModule : HANDLE optional
    Fiddle::TYPE_VOIDP,  # ppwcArguments : LPWSTR* in/out
    -Fiddle::TYPE_INT,  # dwCurrentIndex : DWORD
    -Fiddle::TYPE_INT,  # dwArgCount : DWORD
    Fiddle::TYPE_VOIDP,  # pttTags : TAG_TYPE* optional, in/out
    -Fiddle::TYPE_INT,  # dwTagCount : DWORD
    -Fiddle::TYPE_INT,  # dwMinArgs : DWORD
    -Fiddle::TYPE_INT,  # dwMaxArgs : DWORD
    Fiddle::TYPE_VOIDP,  # pdwTagType : DWORD* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "netsh")]
extern "system" {
    fn PreprocessCommand(
        hModule: *mut core::ffi::c_void,  // HANDLE optional
        ppwcArguments: *mut *mut u16,  // LPWSTR* in/out
        dwCurrentIndex: u32,  // DWORD
        dwArgCount: u32,  // DWORD
        pttTags: *mut TAG_TYPE,  // TAG_TYPE* optional, in/out
        dwTagCount: u32,  // DWORD
        dwMinArgs: u32,  // DWORD
        dwMaxArgs: u32,  // DWORD
        pdwTagType: *mut u32  // DWORD* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NETSH.dll")]
public static extern uint PreprocessCommand(IntPtr hModule, IntPtr ppwcArguments, uint dwCurrentIndex, uint dwArgCount, IntPtr pttTags, uint dwTagCount, uint dwMinArgs, uint dwMaxArgs, IntPtr pdwTagType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETSH_PreprocessCommand' -Namespace Win32 -PassThru
# $api::PreprocessCommand(hModule, ppwcArguments, dwCurrentIndex, dwArgCount, pttTags, dwTagCount, dwMinArgs, dwMaxArgs, pdwTagType)
#uselib "NETSH.dll"
#func global PreprocessCommand "PreprocessCommand" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; PreprocessCommand hModule, varptr(ppwcArguments), dwCurrentIndex, dwArgCount, varptr(pttTags), dwTagCount, dwMinArgs, dwMaxArgs, varptr(pdwTagType)   ; 戻り値は stat
; hModule : HANDLE optional -> "sptr"
; ppwcArguments : LPWSTR* in/out -> "sptr"
; dwCurrentIndex : DWORD -> "sptr"
; dwArgCount : DWORD -> "sptr"
; pttTags : TAG_TYPE* optional, in/out -> "sptr"
; dwTagCount : DWORD -> "sptr"
; dwMinArgs : DWORD -> "sptr"
; dwMaxArgs : DWORD -> "sptr"
; pdwTagType : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "NETSH.dll"
#cfunc global PreprocessCommand "PreprocessCommand" sptr, var, int, int, var, int, int, int, var
; res = PreprocessCommand(hModule, ppwcArguments, dwCurrentIndex, dwArgCount, pttTags, dwTagCount, dwMinArgs, dwMaxArgs, pdwTagType)
; hModule : HANDLE optional -> "sptr"
; ppwcArguments : LPWSTR* in/out -> "var"
; dwCurrentIndex : DWORD -> "int"
; dwArgCount : DWORD -> "int"
; pttTags : TAG_TYPE* optional, in/out -> "var"
; dwTagCount : DWORD -> "int"
; dwMinArgs : DWORD -> "int"
; dwMaxArgs : DWORD -> "int"
; pdwTagType : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PreprocessCommand(HANDLE hModule, LPWSTR* ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, TAG_TYPE* pttTags, DWORD dwTagCount, DWORD dwMinArgs, DWORD dwMaxArgs, DWORD* pdwTagType)
#uselib "NETSH.dll"
#cfunc global PreprocessCommand "PreprocessCommand" intptr, var, int, int, var, int, int, int, var
; res = PreprocessCommand(hModule, ppwcArguments, dwCurrentIndex, dwArgCount, pttTags, dwTagCount, dwMinArgs, dwMaxArgs, pdwTagType)
; hModule : HANDLE optional -> "intptr"
; ppwcArguments : LPWSTR* in/out -> "var"
; dwCurrentIndex : DWORD -> "int"
; dwArgCount : DWORD -> "int"
; pttTags : TAG_TYPE* optional, in/out -> "var"
; dwTagCount : DWORD -> "int"
; dwMinArgs : DWORD -> "int"
; dwMaxArgs : DWORD -> "int"
; pdwTagType : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	netsh = windows.NewLazySystemDLL("NETSH.dll")
	procPreprocessCommand = netsh.NewProc("PreprocessCommand")
)

// hModule (HANDLE optional), ppwcArguments (LPWSTR* in/out), dwCurrentIndex (DWORD), dwArgCount (DWORD), pttTags (TAG_TYPE* optional, in/out), dwTagCount (DWORD), dwMinArgs (DWORD), dwMaxArgs (DWORD), pdwTagType (DWORD* optional, out)
r1, _, err := procPreprocessCommand.Call(
	uintptr(hModule),
	uintptr(ppwcArguments),
	uintptr(dwCurrentIndex),
	uintptr(dwArgCount),
	uintptr(pttTags),
	uintptr(dwTagCount),
	uintptr(dwMinArgs),
	uintptr(dwMaxArgs),
	uintptr(pdwTagType),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PreprocessCommand(
  hModule: THandle;   // HANDLE optional
  ppwcArguments: PPWideChar;   // LPWSTR* in/out
  dwCurrentIndex: DWORD;   // DWORD
  dwArgCount: DWORD;   // DWORD
  pttTags: Pointer;   // TAG_TYPE* optional, in/out
  dwTagCount: DWORD;   // DWORD
  dwMinArgs: DWORD;   // DWORD
  dwMaxArgs: DWORD;   // DWORD
  pdwTagType: Pointer   // DWORD* optional, out
): DWORD; stdcall;
  external 'NETSH.dll' name 'PreprocessCommand';
result := DllCall("NETSH\PreprocessCommand"
    , "Ptr", hModule   ; HANDLE optional
    , "Ptr", ppwcArguments   ; LPWSTR* in/out
    , "UInt", dwCurrentIndex   ; DWORD
    , "UInt", dwArgCount   ; DWORD
    , "Ptr", pttTags   ; TAG_TYPE* optional, in/out
    , "UInt", dwTagCount   ; DWORD
    , "UInt", dwMinArgs   ; DWORD
    , "UInt", dwMaxArgs   ; DWORD
    , "Ptr", pdwTagType   ; DWORD* optional, out
    , "UInt")   ; return: DWORD
●PreprocessCommand(hModule, ppwcArguments, dwCurrentIndex, dwArgCount, pttTags, dwTagCount, dwMinArgs, dwMaxArgs, pdwTagType) = DLL("NETSH.dll", "dword PreprocessCommand(void*, void*, dword, dword, void*, dword, dword, dword, void*)")
# 呼び出し: PreprocessCommand(hModule, ppwcArguments, dwCurrentIndex, dwArgCount, pttTags, dwTagCount, dwMinArgs, dwMaxArgs, pdwTagType)
# hModule : HANDLE optional -> "void*"
# ppwcArguments : LPWSTR* in/out -> "void*"
# dwCurrentIndex : DWORD -> "dword"
# dwArgCount : DWORD -> "dword"
# pttTags : TAG_TYPE* optional, in/out -> "void*"
# dwTagCount : DWORD -> "dword"
# dwMinArgs : DWORD -> "dword"
# dwMaxArgs : DWORD -> "dword"
# pdwTagType : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。