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

MsiAdvertiseProductW

関数
製品をシステムにアドバタイズ(広告登録)する(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiAdvertiseProductW(
    LPCWSTR szPackagePath,
    LPCWSTR szScriptfilePath,   // optional
    LPCWSTR szTransforms,   // optional
    WORD lgidLanguage
);

パラメーター

名前方向
szPackagePathLPCWSTRin
szScriptfilePathLPCWSTRinoptional
szTransformsLPCWSTRinoptional
lgidLanguageWORDin

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiAdvertiseProductW(
    LPCWSTR szPackagePath,
    LPCWSTR szScriptfilePath,   // optional
    LPCWSTR szTransforms,   // optional
    WORD lgidLanguage
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiAdvertiseProductW(
    [MarshalAs(UnmanagedType.LPWStr)] string szPackagePath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szScriptfilePath,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string szTransforms,   // LPCWSTR optional
    ushort lgidLanguage   // WORD
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiAdvertiseProductW(
    <MarshalAs(UnmanagedType.LPWStr)> szPackagePath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szScriptfilePath As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> szTransforms As String,   ' LPCWSTR optional
    lgidLanguage As UShort   ' WORD
) As UInteger
End Function
' szPackagePath : LPCWSTR
' szScriptfilePath : LPCWSTR optional
' szTransforms : LPCWSTR optional
' lgidLanguage : WORD
Declare PtrSafe Function MsiAdvertiseProductW Lib "msi" ( _
    ByVal szPackagePath As LongPtr, _
    ByVal szScriptfilePath As LongPtr, _
    ByVal szTransforms As LongPtr, _
    ByVal lgidLanguage As Integer) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiAdvertiseProductW = ctypes.windll.msi.MsiAdvertiseProductW
MsiAdvertiseProductW.restype = wintypes.DWORD
MsiAdvertiseProductW.argtypes = [
    wintypes.LPCWSTR,  # szPackagePath : LPCWSTR
    wintypes.LPCWSTR,  # szScriptfilePath : LPCWSTR optional
    wintypes.LPCWSTR,  # szTransforms : LPCWSTR optional
    ctypes.c_ushort,  # lgidLanguage : WORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiAdvertiseProductW = Fiddle::Function.new(
  lib['MsiAdvertiseProductW'],
  [
    Fiddle::TYPE_VOIDP,  # szPackagePath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szScriptfilePath : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # szTransforms : LPCWSTR optional
    -Fiddle::TYPE_SHORT,  # lgidLanguage : WORD
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiAdvertiseProductW(
        szPackagePath: *const u16,  // LPCWSTR
        szScriptfilePath: *const u16,  // LPCWSTR optional
        szTransforms: *const u16,  // LPCWSTR optional
        lgidLanguage: u16  // WORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiAdvertiseProductW([MarshalAs(UnmanagedType.LPWStr)] string szPackagePath, [MarshalAs(UnmanagedType.LPWStr)] string szScriptfilePath, [MarshalAs(UnmanagedType.LPWStr)] string szTransforms, ushort lgidLanguage);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiAdvertiseProductW' -Namespace Win32 -PassThru
# $api::MsiAdvertiseProductW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage)
#uselib "msi.dll"
#func global MsiAdvertiseProductW "MsiAdvertiseProductW" wptr, wptr, wptr, wptr
; MsiAdvertiseProductW szPackagePath, szScriptfilePath, szTransforms, lgidLanguage   ; 戻り値は stat
; szPackagePath : LPCWSTR -> "wptr"
; szScriptfilePath : LPCWSTR optional -> "wptr"
; szTransforms : LPCWSTR optional -> "wptr"
; lgidLanguage : WORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiAdvertiseProductW "MsiAdvertiseProductW" wstr, wstr, wstr, int
; res = MsiAdvertiseProductW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage)
; szPackagePath : LPCWSTR -> "wstr"
; szScriptfilePath : LPCWSTR optional -> "wstr"
; szTransforms : LPCWSTR optional -> "wstr"
; lgidLanguage : WORD -> "int"
; DWORD MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath, LPCWSTR szTransforms, WORD lgidLanguage)
#uselib "msi.dll"
#cfunc global MsiAdvertiseProductW "MsiAdvertiseProductW" wstr, wstr, wstr, int
; res = MsiAdvertiseProductW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage)
; szPackagePath : LPCWSTR -> "wstr"
; szScriptfilePath : LPCWSTR optional -> "wstr"
; szTransforms : LPCWSTR optional -> "wstr"
; lgidLanguage : WORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiAdvertiseProductW = msi.NewProc("MsiAdvertiseProductW")
)

// szPackagePath (LPCWSTR), szScriptfilePath (LPCWSTR optional), szTransforms (LPCWSTR optional), lgidLanguage (WORD)
r1, _, err := procMsiAdvertiseProductW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szPackagePath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szScriptfilePath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szTransforms))),
	uintptr(lgidLanguage),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiAdvertiseProductW(
  szPackagePath: PWideChar;   // LPCWSTR
  szScriptfilePath: PWideChar;   // LPCWSTR optional
  szTransforms: PWideChar;   // LPCWSTR optional
  lgidLanguage: Word   // WORD
): DWORD; stdcall;
  external 'msi.dll' name 'MsiAdvertiseProductW';
result := DllCall("msi\MsiAdvertiseProductW"
    , "WStr", szPackagePath   ; LPCWSTR
    , "WStr", szScriptfilePath   ; LPCWSTR optional
    , "WStr", szTransforms   ; LPCWSTR optional
    , "UShort", lgidLanguage   ; WORD
    , "UInt")   ; return: DWORD
●MsiAdvertiseProductW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage) = DLL("msi.dll", "dword MsiAdvertiseProductW(char*, char*, char*, int)")
# 呼び出し: MsiAdvertiseProductW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage)
# szPackagePath : LPCWSTR -> "char*"
# szScriptfilePath : LPCWSTR optional -> "char*"
# szTransforms : LPCWSTR optional -> "char*"
# lgidLanguage : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。