ホーム › System.ApplicationInstallationAndServicing › MsiGetTargetPathA
MsiGetTargetPathA
関数フォルダーのターゲットパスを完全な形で取得する(ANSI版)。
シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiGetTargetPathA(
MSIHANDLE hInstall,
LPCSTR szFolder,
LPSTR szPathBuf, // optional
DWORD* pcchPathBuf // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstall | MSIHANDLE | in |
| szFolder | LPCSTR | in |
| szPathBuf | LPSTR | outoptional |
| pcchPathBuf | DWORD* | inoutoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiGetTargetPathA(
MSIHANDLE hInstall,
LPCSTR szFolder,
LPSTR szPathBuf, // optional
DWORD* pcchPathBuf // optional
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiGetTargetPathA(
uint hInstall, // MSIHANDLE
[MarshalAs(UnmanagedType.LPStr)] string szFolder, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szPathBuf, // LPSTR optional, out
IntPtr pcchPathBuf // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiGetTargetPathA(
hInstall As UInteger, ' MSIHANDLE
<MarshalAs(UnmanagedType.LPStr)> szFolder As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szPathBuf As System.Text.StringBuilder, ' LPSTR optional, out
pcchPathBuf As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' hInstall : MSIHANDLE
' szFolder : LPCSTR
' szPathBuf : LPSTR optional, out
' pcchPathBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiGetTargetPathA Lib "msi" ( _
ByVal hInstall As Long, _
ByVal szFolder As String, _
ByVal szPathBuf As String, _
ByVal pcchPathBuf As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiGetTargetPathA = ctypes.windll.msi.MsiGetTargetPathA
MsiGetTargetPathA.restype = wintypes.DWORD
MsiGetTargetPathA.argtypes = [
wintypes.DWORD, # hInstall : MSIHANDLE
wintypes.LPCSTR, # szFolder : LPCSTR
wintypes.LPSTR, # szPathBuf : LPSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchPathBuf : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiGetTargetPathA = Fiddle::Function.new(
lib['MsiGetTargetPathA'],
[
-Fiddle::TYPE_INT, # hInstall : MSIHANDLE
Fiddle::TYPE_VOIDP, # szFolder : LPCSTR
Fiddle::TYPE_VOIDP, # szPathBuf : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pcchPathBuf : DWORD* optional, in/out
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiGetTargetPathA(
hInstall: u32, // MSIHANDLE
szFolder: *const u8, // LPCSTR
szPathBuf: *mut u8, // LPSTR optional, out
pcchPathBuf: *mut u32 // DWORD* optional, in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiGetTargetPathA(uint hInstall, [MarshalAs(UnmanagedType.LPStr)] string szFolder, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szPathBuf, IntPtr pcchPathBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetTargetPathA' -Namespace Win32 -PassThru
# $api::MsiGetTargetPathA(hInstall, szFolder, szPathBuf, pcchPathBuf)#uselib "msi.dll"
#func global MsiGetTargetPathA "MsiGetTargetPathA" sptr, sptr, sptr, sptr
; MsiGetTargetPathA hInstall, szFolder, varptr(szPathBuf), varptr(pcchPathBuf) ; 戻り値は stat
; hInstall : MSIHANDLE -> "sptr"
; szFolder : LPCSTR -> "sptr"
; szPathBuf : LPSTR optional, out -> "sptr"
; pcchPathBuf : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiGetTargetPathA "MsiGetTargetPathA" int, str, var, var ; res = MsiGetTargetPathA(hInstall, szFolder, szPathBuf, pcchPathBuf) ; hInstall : MSIHANDLE -> "int" ; szFolder : LPCSTR -> "str" ; szPathBuf : LPSTR optional, out -> "var" ; pcchPathBuf : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiGetTargetPathA "MsiGetTargetPathA" int, str, sptr, sptr ; res = MsiGetTargetPathA(hInstall, szFolder, varptr(szPathBuf), varptr(pcchPathBuf)) ; hInstall : MSIHANDLE -> "int" ; szFolder : LPCSTR -> "str" ; szPathBuf : LPSTR optional, out -> "sptr" ; pcchPathBuf : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MsiGetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, LPSTR szPathBuf, DWORD* pcchPathBuf) #uselib "msi.dll" #cfunc global MsiGetTargetPathA "MsiGetTargetPathA" int, str, var, var ; res = MsiGetTargetPathA(hInstall, szFolder, szPathBuf, pcchPathBuf) ; hInstall : MSIHANDLE -> "int" ; szFolder : LPCSTR -> "str" ; szPathBuf : LPSTR optional, out -> "var" ; pcchPathBuf : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiGetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, LPSTR szPathBuf, DWORD* pcchPathBuf) #uselib "msi.dll" #cfunc global MsiGetTargetPathA "MsiGetTargetPathA" int, str, intptr, intptr ; res = MsiGetTargetPathA(hInstall, szFolder, varptr(szPathBuf), varptr(pcchPathBuf)) ; hInstall : MSIHANDLE -> "int" ; szFolder : LPCSTR -> "str" ; szPathBuf : LPSTR optional, out -> "intptr" ; pcchPathBuf : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiGetTargetPathA = msi.NewProc("MsiGetTargetPathA")
)
// hInstall (MSIHANDLE), szFolder (LPCSTR), szPathBuf (LPSTR optional, out), pcchPathBuf (DWORD* optional, in/out)
r1, _, err := procMsiGetTargetPathA.Call(
uintptr(hInstall),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szFolder))),
uintptr(szPathBuf),
uintptr(pcchPathBuf),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiGetTargetPathA(
hInstall: DWORD; // MSIHANDLE
szFolder: PAnsiChar; // LPCSTR
szPathBuf: PAnsiChar; // LPSTR optional, out
pcchPathBuf: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiGetTargetPathA';result := DllCall("msi\MsiGetTargetPathA"
, "UInt", hInstall ; MSIHANDLE
, "AStr", szFolder ; LPCSTR
, "Ptr", szPathBuf ; LPSTR optional, out
, "Ptr", pcchPathBuf ; DWORD* optional, in/out
, "UInt") ; return: DWORD●MsiGetTargetPathA(hInstall, szFolder, szPathBuf, pcchPathBuf) = DLL("msi.dll", "dword MsiGetTargetPathA(dword, char*, char*, void*)")
# 呼び出し: MsiGetTargetPathA(hInstall, szFolder, szPathBuf, pcchPathBuf)
# hInstall : MSIHANDLE -> "dword"
# szFolder : LPCSTR -> "char*"
# szPathBuf : LPSTR optional, out -> "char*"
# pcchPathBuf : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。