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