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解析を開始する引数配列のインデックスを指定する。
dwArgCountDWORDinppwcArguments内の引数の総数を指定する。
pttTagsTAG_TYPE*inoutoptional有効なタグ定義を保持するTAG_TYPE配列へのポインター。
dwTagCountDWORDinpttTags内のタグ数を指定する。
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)。
const std = @import("std");

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

typedef PreprocessCommandNative = Uint32 Function(Pointer<Void>, Pointer<Pointer<Utf16>>, Uint32, Uint32, Pointer<Void>, Uint32, Uint32, Uint32, Pointer<Uint32>);
typedef PreprocessCommandDart = int Function(Pointer<Void>, Pointer<Pointer<Utf16>>, int, int, Pointer<Void>, int, int, int, Pointer<Uint32>);
final PreprocessCommand = DynamicLibrary.open('NETSH.dll')
    .lookupFunction<PreprocessCommandNative, PreprocessCommandDart>('PreprocessCommand');
// hModule : HANDLE optional -> Pointer<Void>
// ppwcArguments : LPWSTR* in/out -> Pointer<Pointer<Utf16>>
// dwCurrentIndex : DWORD -> Uint32
// dwArgCount : DWORD -> Uint32
// pttTags : TAG_TYPE* optional, in/out -> Pointer<Void>
// dwTagCount : DWORD -> Uint32
// dwMinArgs : DWORD -> Uint32
// dwMaxArgs : DWORD -> Uint32
// pdwTagType : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PreprocessCommand"
  c_PreprocessCommand :: Ptr () -> Ptr CWString -> Word32 -> Word32 -> Ptr () -> Word32 -> Word32 -> Word32 -> Ptr Word32 -> IO Word32
-- hModule : HANDLE optional -> Ptr ()
-- ppwcArguments : LPWSTR* in/out -> Ptr CWString
-- dwCurrentIndex : DWORD -> Word32
-- dwArgCount : DWORD -> Word32
-- pttTags : TAG_TYPE* optional, in/out -> Ptr ()
-- dwTagCount : DWORD -> Word32
-- dwMinArgs : DWORD -> Word32
-- dwMaxArgs : DWORD -> Word32
-- pdwTagType : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let preprocesscommand =
  foreign "PreprocessCommand"
    ((ptr void) @-> (ptr (ptr uint16_t)) @-> uint32_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> returning uint32_t)
(* hModule : HANDLE optional -> (ptr void) *)
(* ppwcArguments : LPWSTR* in/out -> (ptr (ptr uint16_t)) *)
(* dwCurrentIndex : DWORD -> uint32_t *)
(* dwArgCount : DWORD -> uint32_t *)
(* pttTags : TAG_TYPE* optional, in/out -> (ptr void) *)
(* dwTagCount : DWORD -> uint32_t *)
(* dwMinArgs : DWORD -> uint32_t *)
(* dwMaxArgs : DWORD -> uint32_t *)
(* pdwTagType : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library netsh (t "NETSH.dll"))
(cffi:use-foreign-library netsh)

(cffi:defcfun ("PreprocessCommand" preprocess-command :convention :stdcall) :uint32
  (h-module :pointer)   ; HANDLE optional
  (ppwc-arguments :pointer)   ; LPWSTR* in/out
  (dw-current-index :uint32)   ; DWORD
  (dw-arg-count :uint32)   ; DWORD
  (ptt-tags :pointer)   ; TAG_TYPE* optional, in/out
  (dw-tag-count :uint32)   ; DWORD
  (dw-min-args :uint32)   ; DWORD
  (dw-max-args :uint32)   ; DWORD
  (pdw-tag-type :pointer))   ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PreprocessCommand = Win32::API::More->new('NETSH',
    'DWORD PreprocessCommand(HANDLE hModule, LPVOID ppwcArguments, DWORD dwCurrentIndex, DWORD dwArgCount, LPVOID pttTags, DWORD dwTagCount, DWORD dwMinArgs, DWORD dwMaxArgs, LPVOID pdwTagType)');
# my $ret = $PreprocessCommand->Call($hModule, $ppwcArguments, $dwCurrentIndex, $dwArgCount, $pttTags, $dwTagCount, $dwMinArgs, $dwMaxArgs, $pdwTagType);
# hModule : HANDLE optional -> HANDLE
# ppwcArguments : LPWSTR* in/out -> LPVOID
# dwCurrentIndex : DWORD -> DWORD
# dwArgCount : DWORD -> DWORD
# pttTags : TAG_TYPE* optional, in/out -> LPVOID
# dwTagCount : DWORD -> DWORD
# dwMinArgs : DWORD -> DWORD
# dwMaxArgs : DWORD -> DWORD
# pdwTagType : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型