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

MsiGetShortcutTargetA

関数
ショートカットから製品、フィーチャー、コンポーネントの情報を取得する。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiGetShortcutTargetA(
    LPCSTR szShortcutPath,
    LPSTR szProductCode,   // optional
    LPSTR szFeatureId,   // optional
    LPSTR szComponentCode   // optional
);

パラメーター

名前方向
szShortcutPathLPCSTRin
szProductCodeLPSTRoutoptional
szFeatureIdLPSTRoutoptional
szComponentCodeLPSTRoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiGetShortcutTargetA(
    LPCSTR szShortcutPath,
    LPSTR szProductCode,   // optional
    LPSTR szFeatureId,   // optional
    LPSTR szComponentCode   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiGetShortcutTargetA(
    [MarshalAs(UnmanagedType.LPStr)] string szShortcutPath,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szProductCode,   // LPSTR optional, out
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szFeatureId,   // LPSTR optional, out
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szComponentCode   // LPSTR optional, out
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiGetShortcutTargetA(
    <MarshalAs(UnmanagedType.LPStr)> szShortcutPath As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szProductCode As System.Text.StringBuilder,   ' LPSTR optional, out
    <MarshalAs(UnmanagedType.LPStr)> szFeatureId As System.Text.StringBuilder,   ' LPSTR optional, out
    <MarshalAs(UnmanagedType.LPStr)> szComponentCode As System.Text.StringBuilder   ' LPSTR optional, out
) As UInteger
End Function
' szShortcutPath : LPCSTR
' szProductCode : LPSTR optional, out
' szFeatureId : LPSTR optional, out
' szComponentCode : LPSTR optional, out
Declare PtrSafe Function MsiGetShortcutTargetA Lib "msi" ( _
    ByVal szShortcutPath As String, _
    ByVal szProductCode As String, _
    ByVal szFeatureId As String, _
    ByVal szComponentCode As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiGetShortcutTargetA = ctypes.windll.msi.MsiGetShortcutTargetA
MsiGetShortcutTargetA.restype = wintypes.DWORD
MsiGetShortcutTargetA.argtypes = [
    wintypes.LPCSTR,  # szShortcutPath : LPCSTR
    wintypes.LPSTR,  # szProductCode : LPSTR optional, out
    wintypes.LPSTR,  # szFeatureId : LPSTR optional, out
    wintypes.LPSTR,  # szComponentCode : LPSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiGetShortcutTargetA = Fiddle::Function.new(
  lib['MsiGetShortcutTargetA'],
  [
    Fiddle::TYPE_VOIDP,  # szShortcutPath : LPCSTR
    Fiddle::TYPE_VOIDP,  # szProductCode : LPSTR optional, out
    Fiddle::TYPE_VOIDP,  # szFeatureId : LPSTR optional, out
    Fiddle::TYPE_VOIDP,  # szComponentCode : LPSTR optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiGetShortcutTargetA(
        szShortcutPath: *const u8,  // LPCSTR
        szProductCode: *mut u8,  // LPSTR optional, out
        szFeatureId: *mut u8,  // LPSTR optional, out
        szComponentCode: *mut u8  // LPSTR optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiGetShortcutTargetA([MarshalAs(UnmanagedType.LPStr)] string szShortcutPath, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szProductCode, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szFeatureId, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szComponentCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetShortcutTargetA' -Namespace Win32 -PassThru
# $api::MsiGetShortcutTargetA(szShortcutPath, szProductCode, szFeatureId, szComponentCode)
#uselib "msi.dll"
#func global MsiGetShortcutTargetA "MsiGetShortcutTargetA" sptr, sptr, sptr, sptr
; MsiGetShortcutTargetA szShortcutPath, varptr(szProductCode), varptr(szFeatureId), varptr(szComponentCode)   ; 戻り値は stat
; szShortcutPath : LPCSTR -> "sptr"
; szProductCode : LPSTR optional, out -> "sptr"
; szFeatureId : LPSTR optional, out -> "sptr"
; szComponentCode : LPSTR optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiGetShortcutTargetA "MsiGetShortcutTargetA" str, var, var, var
; res = MsiGetShortcutTargetA(szShortcutPath, szProductCode, szFeatureId, szComponentCode)
; szShortcutPath : LPCSTR -> "str"
; szProductCode : LPSTR optional, out -> "var"
; szFeatureId : LPSTR optional, out -> "var"
; szComponentCode : LPSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiGetShortcutTargetA(LPCSTR szShortcutPath, LPSTR szProductCode, LPSTR szFeatureId, LPSTR szComponentCode)
#uselib "msi.dll"
#cfunc global MsiGetShortcutTargetA "MsiGetShortcutTargetA" str, var, var, var
; res = MsiGetShortcutTargetA(szShortcutPath, szProductCode, szFeatureId, szComponentCode)
; szShortcutPath : LPCSTR -> "str"
; szProductCode : LPSTR optional, out -> "var"
; szFeatureId : LPSTR optional, out -> "var"
; szComponentCode : LPSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiGetShortcutTargetA = msi.NewProc("MsiGetShortcutTargetA")
)

// szShortcutPath (LPCSTR), szProductCode (LPSTR optional, out), szFeatureId (LPSTR optional, out), szComponentCode (LPSTR optional, out)
r1, _, err := procMsiGetShortcutTargetA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szShortcutPath))),
	uintptr(szProductCode),
	uintptr(szFeatureId),
	uintptr(szComponentCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiGetShortcutTargetA(
  szShortcutPath: PAnsiChar;   // LPCSTR
  szProductCode: PAnsiChar;   // LPSTR optional, out
  szFeatureId: PAnsiChar;   // LPSTR optional, out
  szComponentCode: PAnsiChar   // LPSTR optional, out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiGetShortcutTargetA';
result := DllCall("msi\MsiGetShortcutTargetA"
    , "AStr", szShortcutPath   ; LPCSTR
    , "Ptr", szProductCode   ; LPSTR optional, out
    , "Ptr", szFeatureId   ; LPSTR optional, out
    , "Ptr", szComponentCode   ; LPSTR optional, out
    , "UInt")   ; return: DWORD
●MsiGetShortcutTargetA(szShortcutPath, szProductCode, szFeatureId, szComponentCode) = DLL("msi.dll", "dword MsiGetShortcutTargetA(char*, char*, char*, char*)")
# 呼び出し: MsiGetShortcutTargetA(szShortcutPath, szProductCode, szFeatureId, szComponentCode)
# szShortcutPath : LPCSTR -> "char*"
# szProductCode : LPSTR optional, out -> "char*"
# szFeatureId : LPSTR optional, out -> "char*"
# szComponentCode : LPSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。