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

MsiAdvertiseProductExW

関数
オプション指定で製品をアドバタイズする(Unicode版)。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiAdvertiseProductExW(
    LPCWSTR szPackagePath,
    LPCWSTR szScriptfilePath,   // optional
    LPCWSTR szTransforms,   // optional
    WORD lgidLanguage,
    DWORD dwPlatform,
    DWORD dwOptions
);

パラメーター

名前方向説明
szPackagePathLPCWSTRinアドバタイズする製品のパッケージへのフルパスです。
szScriptfilePathLPCWSTRinoptional

アドバタイズ情報を使用して作成されるスクリプトファイルへのフルパスです。製品をローカルコンピューターにアドバタイズするには、ADVERTISEFLAGS_MACHINEASSIGN または ADVERTISEFLAGS_USERASSIGN を設定します。

Flag Meaning
ADVERTISEFLAGS_MACHINEASSIGN
0
すべてのユーザーが使用できる、製品のコンピューター単位のインストールをアドバタイズする場合に設定します。
ADVERTISEFLAGS_USERASSIGN
1
特定のユーザーが使用できる、製品のユーザー単位のインストールをアドバタイズする場合に設定します。
szTransformsLPCWSTRinoptional適用する変換 (トランスフォーム) をセミコロンで区切ったリストです。変換のリストには、変換のセキュアキャッシュを指定するために @ または | 文字をプレフィックスとして付けることができます。@ プレフィックスはソースでセキュアな変換を指定し、| プレフィックスはフルパスでセキュアな変換を示します。詳細については、 Secured Transforms を参照してください。このパラメーターは null にできます。
lgidLanguageWORDinソースが複数の言語をサポートしている場合に使用する言語です。
dwPlatformDWORDin

インストーラーがどのプラットフォーム向けにスクリプトを作成するかを制御するビットフラグです。szScriptfilePath が null の場合、このパラメーターは無視されます。dwPlatform がゼロ (0) の場合、スクリプトは現在のプラットフォームに基づいて作成されます。これは MsiAdvertiseProduct と同じ機能です。dwPlatform が 1 または 2 の場合、インストーラーは指定されたプラットフォーム向けのスクリプトを作成します。

Flag Meaning
none
0
現在のプラットフォーム向けのスクリプトを作成します。
MSIARCHITECTUREFLAGS_X86
1
x86 プラットフォーム向けのスクリプトを作成します。
MSIARCHITECTUREFLAGS_IA64
2
Itanium ベースのシステム向けのスクリプトを作成します。
MSIARCHITECTUREFLAGS_AMD64
4
x64 プラットフォーム向けのスクリプトを作成します。
dwOptionsDWORDin

追加のアドバタイズオプションを指定するビットフラグです。ゼロ以外の値は、Windows Server 2003 および Windows XP with SP1 以降に付属する Windows Installer のバージョンでのみ使用できます。

Flag Meaning
MSIADVERTISEOPTIONS_INSTANCE
1
製品コードを変更する変換による複数インスタンスのサポートフラグです。製品の新しいインスタンスをアドバタイズします。szTransforms パラメーターに、製品コードを変更するインスタンス変換が含まれている必要があります。詳細については、Installing Multiple Instances of Products and Patches を参照してください。

戻り値の型: DWORD

公式ドキュメント

MsiAdvertiseProductEx 関数は、アドバタイズスクリプトを生成するか、または製品をコンピューターにアドバタイズします。(Unicode)

戻り値

Value Meaning
ERROR_SUCCESS
関数は正常に完了します。
An error that relates to an action
詳細については、 Error Codes を参照してください。
Initialization Error
初期化エラーが発生しました。
ERROR_CALL_NOT_IMPLEMENTED
このエラーは、Windows 2000 または Windows XP 以外のプラットフォームでアドバタイズスクリプトを生成しようとした場合に返されます。ローカルコンピューターへのアドバタイズは、すべてのプラットフォームでサポートされています。

解説(Remarks)

製品コードを変更する変換による複数インスタンスは、Windows Server 2003 および Windows XP with SP1 以降に付属する Windows Installer のバージョンでのみ使用できます。

メモ

msi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiAdvertiseProductEx を定義します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じ、コンパイルエラーまたは実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

DWORD MsiAdvertiseProductExW(
    LPCWSTR szPackagePath,
    LPCWSTR szScriptfilePath,   // optional
    LPCWSTR szTransforms,   // optional
    WORD lgidLanguage,
    DWORD dwPlatform,
    DWORD dwOptions
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiAdvertiseProductExW(
    [MarshalAs(UnmanagedType.LPWStr)] string szPackagePath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szScriptfilePath,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string szTransforms,   // LPCWSTR optional
    ushort lgidLanguage,   // WORD
    uint dwPlatform,   // DWORD
    uint dwOptions   // DWORD
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiAdvertiseProductExW(
    <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
    dwPlatform As UInteger,   ' DWORD
    dwOptions As UInteger   ' DWORD
) As UInteger
End Function
' szPackagePath : LPCWSTR
' szScriptfilePath : LPCWSTR optional
' szTransforms : LPCWSTR optional
' lgidLanguage : WORD
' dwPlatform : DWORD
' dwOptions : DWORD
Declare PtrSafe Function MsiAdvertiseProductExW Lib "msi" ( _
    ByVal szPackagePath As LongPtr, _
    ByVal szScriptfilePath As LongPtr, _
    ByVal szTransforms As LongPtr, _
    ByVal lgidLanguage As Integer, _
    ByVal dwPlatform As Long, _
    ByVal dwOptions As Long) 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

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

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiAdvertiseProductExW = msi.NewProc("MsiAdvertiseProductExW")
)

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

extern "msi" fn MsiAdvertiseProductExW(
    szPackagePath: [*c]const u16, // LPCWSTR
    szScriptfilePath: [*c]const u16, // LPCWSTR optional
    szTransforms: [*c]const u16, // LPCWSTR optional
    lgidLanguage: u16, // WORD
    dwPlatform: u32, // DWORD
    dwOptions: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc MsiAdvertiseProductExW(
    szPackagePath: WideCString,  # LPCWSTR
    szScriptfilePath: WideCString,  # LPCWSTR optional
    szTransforms: WideCString,  # LPCWSTR optional
    lgidLanguage: uint16,  # WORD
    dwPlatform: uint32,  # DWORD
    dwOptions: uint32  # DWORD
): uint32 {.importc: "MsiAdvertiseProductExW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "msi");
extern(Windows)
uint MsiAdvertiseProductExW(
    const(wchar)* szPackagePath,   // LPCWSTR
    const(wchar)* szScriptfilePath,   // LPCWSTR optional
    const(wchar)* szTransforms,   // LPCWSTR optional
    ushort lgidLanguage,   // WORD
    uint dwPlatform,   // DWORD
    uint dwOptions   // DWORD
);
ccall((:MsiAdvertiseProductExW, "msi.dll"), stdcall, UInt32,
      (Cwstring, Cwstring, Cwstring, UInt16, UInt32, UInt32),
      szPackagePath, szScriptfilePath, szTransforms, lgidLanguage, dwPlatform, dwOptions)
# szPackagePath : LPCWSTR -> Cwstring
# szScriptfilePath : LPCWSTR optional -> Cwstring
# szTransforms : LPCWSTR optional -> Cwstring
# lgidLanguage : WORD -> UInt16
# dwPlatform : DWORD -> UInt32
# dwOptions : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiAdvertiseProductExW(
    const uint16_t* szPackagePath,
    const uint16_t* szScriptfilePath,
    const uint16_t* szTransforms,
    uint16_t lgidLanguage,
    uint32_t dwPlatform,
    uint32_t dwOptions);
]]
local msi = ffi.load("msi")
-- msi.MsiAdvertiseProductExW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage, dwPlatform, dwOptions)
-- szPackagePath : LPCWSTR
-- szScriptfilePath : LPCWSTR optional
-- szTransforms : LPCWSTR optional
-- lgidLanguage : WORD
-- dwPlatform : DWORD
-- dwOptions : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiAdvertiseProductExW = lib.func('__stdcall', 'MsiAdvertiseProductExW', 'uint32_t', ['str16', 'str16', 'str16', 'uint16_t', 'uint32_t', 'uint32_t']);
// MsiAdvertiseProductExW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage, dwPlatform, dwOptions)
// szPackagePath : LPCWSTR -> 'str16'
// szScriptfilePath : LPCWSTR optional -> 'str16'
// szTransforms : LPCWSTR optional -> 'str16'
// lgidLanguage : WORD -> 'uint16_t'
// dwPlatform : DWORD -> 'uint32_t'
// dwOptions : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msi.dll", {
  MsiAdvertiseProductExW: { parameters: ["buffer", "buffer", "buffer", "u16", "u32", "u32"], result: "u32" },
});
// lib.symbols.MsiAdvertiseProductExW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage, dwPlatform, dwOptions)
// szPackagePath : LPCWSTR -> "buffer"
// szScriptfilePath : LPCWSTR optional -> "buffer"
// szTransforms : LPCWSTR optional -> "buffer"
// lgidLanguage : WORD -> "u16"
// dwPlatform : DWORD -> "u32"
// dwOptions : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiAdvertiseProductExW(
    const uint16_t* szPackagePath,
    const uint16_t* szScriptfilePath,
    const uint16_t* szTransforms,
    uint16_t lgidLanguage,
    uint32_t dwPlatform,
    uint32_t dwOptions);
C, "msi.dll");
// $ffi->MsiAdvertiseProductExW(szPackagePath, szScriptfilePath, szTransforms, lgidLanguage, dwPlatform, dwOptions);
// szPackagePath : LPCWSTR
// szScriptfilePath : LPCWSTR optional
// szTransforms : LPCWSTR optional
// lgidLanguage : WORD
// dwPlatform : DWORD
// dwOptions : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Msi extends StdCallLibrary {
    Msi INSTANCE = Native.load("msi", Msi.class, W32APIOptions.UNICODE_OPTIONS);
    int MsiAdvertiseProductExW(
        WString szPackagePath,   // LPCWSTR
        WString szScriptfilePath,   // LPCWSTR optional
        WString szTransforms,   // LPCWSTR optional
        short lgidLanguage,   // WORD
        int dwPlatform,   // DWORD
        int dwOptions   // DWORD
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("msi")]
lib Libmsi
  fun MsiAdvertiseProductExW = MsiAdvertiseProductExW(
    szPackagePath : UInt16*,   # LPCWSTR
    szScriptfilePath : UInt16*,   # LPCWSTR optional
    szTransforms : UInt16*,   # LPCWSTR optional
    lgidLanguage : UInt16,   # WORD
    dwPlatform : UInt32,   # DWORD
    dwOptions : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MsiAdvertiseProductExWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint16, Uint32, Uint32);
typedef MsiAdvertiseProductExWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int, int, int);
final MsiAdvertiseProductExW = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiAdvertiseProductExWNative, MsiAdvertiseProductExWDart>('MsiAdvertiseProductExW');
// szPackagePath : LPCWSTR -> Pointer<Utf16>
// szScriptfilePath : LPCWSTR optional -> Pointer<Utf16>
// szTransforms : LPCWSTR optional -> Pointer<Utf16>
// lgidLanguage : WORD -> Uint16
// dwPlatform : DWORD -> Uint32
// dwOptions : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiAdvertiseProductExW(
  szPackagePath: PWideChar;   // LPCWSTR
  szScriptfilePath: PWideChar;   // LPCWSTR optional
  szTransforms: PWideChar;   // LPCWSTR optional
  lgidLanguage: Word;   // WORD
  dwPlatform: DWORD;   // DWORD
  dwOptions: DWORD   // DWORD
): DWORD; stdcall;
  external 'msi.dll' name 'MsiAdvertiseProductExW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiAdvertiseProductExW"
  c_MsiAdvertiseProductExW :: CWString -> CWString -> CWString -> Word16 -> Word32 -> Word32 -> IO Word32
-- szPackagePath : LPCWSTR -> CWString
-- szScriptfilePath : LPCWSTR optional -> CWString
-- szTransforms : LPCWSTR optional -> CWString
-- lgidLanguage : WORD -> Word16
-- dwPlatform : DWORD -> Word32
-- dwOptions : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let msiadvertiseproductexw =
  foreign "MsiAdvertiseProductExW"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint16_t @-> uint32_t @-> uint32_t @-> returning uint32_t)
(* szPackagePath : LPCWSTR -> (ptr uint16_t) *)
(* szScriptfilePath : LPCWSTR optional -> (ptr uint16_t) *)
(* szTransforms : LPCWSTR optional -> (ptr uint16_t) *)
(* lgidLanguage : WORD -> uint16_t *)
(* dwPlatform : DWORD -> uint32_t *)
(* dwOptions : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)

(cffi:defcfun ("MsiAdvertiseProductExW" msi-advertise-product-ex-w :convention :stdcall) :uint32
  (sz-package-path (:string :encoding :utf-16le))   ; LPCWSTR
  (sz-scriptfile-path (:string :encoding :utf-16le))   ; LPCWSTR optional
  (sz-transforms (:string :encoding :utf-16le))   ; LPCWSTR optional
  (lgid-language :uint16)   ; WORD
  (dw-platform :uint32)   ; DWORD
  (dw-options :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MsiAdvertiseProductExW = Win32::API::More->new('msi',
    'DWORD MsiAdvertiseProductExW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath, LPCWSTR szTransforms, WORD lgidLanguage, DWORD dwPlatform, DWORD dwOptions)');
# my $ret = $MsiAdvertiseProductExW->Call($szPackagePath, $szScriptfilePath, $szTransforms, $lgidLanguage, $dwPlatform, $dwOptions);
# szPackagePath : LPCWSTR -> LPCWSTR
# szScriptfilePath : LPCWSTR optional -> LPCWSTR
# szTransforms : LPCWSTR optional -> LPCWSTR
# lgidLanguage : WORD -> WORD
# dwPlatform : DWORD -> DWORD
# dwOptions : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
類似 API