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