Win32 API 日本語リファレンス
ホームSystem.ApplicationInstallationAndServicing › MsiGetSourcePathA

MsiGetSourcePathA

関数
フォルダーのソースパスを完全な形で取得する(ANSI版)。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiGetSourcePathA(
    MSIHANDLE hInstall,
    LPCSTR szFolder,
    LPSTR szPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);

パラメーター

名前方向
hInstallMSIHANDLEin
szFolderLPCSTRin
szPathBufLPSTRoutoptional
pcchPathBufDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiGetSourcePathA(
    MSIHANDLE hInstall,
    LPCSTR szFolder,
    LPSTR szPathBuf,   // optional
    DWORD* pcchPathBuf   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiGetSourcePathA(
    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 MsiGetSourcePathA(
    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 MsiGetSourcePathA 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

MsiGetSourcePathA = ctypes.windll.msi.MsiGetSourcePathA
MsiGetSourcePathA.restype = wintypes.DWORD
MsiGetSourcePathA.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')
MsiGetSourcePathA = Fiddle::Function.new(
  lib['MsiGetSourcePathA'],
  [
    -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 MsiGetSourcePathA(
        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 MsiGetSourcePathA(uint hInstall, [MarshalAs(UnmanagedType.LPStr)] string szFolder, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szPathBuf, IntPtr pcchPathBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetSourcePathA' -Namespace Win32 -PassThru
# $api::MsiGetSourcePathA(hInstall, szFolder, szPathBuf, pcchPathBuf)
#uselib "msi.dll"
#func global MsiGetSourcePathA "MsiGetSourcePathA" sptr, sptr, sptr, sptr
; MsiGetSourcePathA 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 MsiGetSourcePathA "MsiGetSourcePathA" int, str, var, var
; res = MsiGetSourcePathA(hInstall, szFolder, szPathBuf, pcchPathBuf)
; hInstall : MSIHANDLE -> "int"
; szFolder : LPCSTR -> "str"
; szPathBuf : LPSTR optional, out -> "var"
; pcchPathBuf : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiGetSourcePathA(MSIHANDLE hInstall, LPCSTR szFolder, LPSTR szPathBuf, DWORD* pcchPathBuf)
#uselib "msi.dll"
#cfunc global MsiGetSourcePathA "MsiGetSourcePathA" int, str, var, var
; res = MsiGetSourcePathA(hInstall, szFolder, szPathBuf, pcchPathBuf)
; hInstall : MSIHANDLE -> "int"
; szFolder : LPCSTR -> "str"
; szPathBuf : LPSTR optional, out -> "var"
; pcchPathBuf : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiGetSourcePathA = msi.NewProc("MsiGetSourcePathA")
)

// hInstall (MSIHANDLE), szFolder (LPCSTR), szPathBuf (LPSTR optional, out), pcchPathBuf (DWORD* optional, in/out)
r1, _, err := procMsiGetSourcePathA.Call(
	uintptr(hInstall),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szFolder))),
	uintptr(szPathBuf),
	uintptr(pcchPathBuf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiGetSourcePathA(
  hInstall: DWORD;   // MSIHANDLE
  szFolder: PAnsiChar;   // LPCSTR
  szPathBuf: PAnsiChar;   // LPSTR optional, out
  pcchPathBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiGetSourcePathA';
result := DllCall("msi\MsiGetSourcePathA"
    , "UInt", hInstall   ; MSIHANDLE
    , "AStr", szFolder   ; LPCSTR
    , "Ptr", szPathBuf   ; LPSTR optional, out
    , "Ptr", pcchPathBuf   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiGetSourcePathA(hInstall, szFolder, szPathBuf, pcchPathBuf) = DLL("msi.dll", "dword MsiGetSourcePathA(dword, char*, char*, void*)")
# 呼び出し: MsiGetSourcePathA(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)。