ホーム › System.ApplicationInstallationAndServicing › MsiEnableLogA
MsiEnableLogA
関数インストーラのログ出力を有効化する(ANSI版)。
シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiEnableLogA(
DWORD dwLogMode,
LPCSTR szLogFile, // optional
DWORD dwLogAttributes
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| dwLogMode | DWORD | in | ログモードを指定します。このパラメーターには、次の値の 1 つ以上を指定できます。
| ||||||||||||||||||||||||||||||
| szLogFile | LPCSTR | inoptional | ログファイルへのフルパスを保持する文字列を指定します。null を指定するとログ記録が無効になり、その場合 dwlogmode は無視されます。パスを指定する場合は、dwlogmode をゼロにすることはできません。 | ||||||||||||||||||||||||||||||
| dwLogAttributes | DWORD | in | ログバッファーをフラッシュする頻度を指定します。
|
戻り値の型: DWORD
公式ドキュメント
MsiEnableLog 関数は、呼び出し元プロセスで以降に開始されるすべてのインストールに対するログモードを設定します。(ANSI)
戻り値
| Value | Meaning |
|---|---|
| 無効なログモードが指定されました。 | |
| 関数は成功しました。 |
解説(Remarks)
ログ記録ポリシーの説明については、 System Policy を参照してください。
この関数を使用する場合、ログファイルの場所へのパスがあらかじめ存在している必要があります。インストーラーはログファイル用のディレクトリ構造を作成しません。
メモ
msi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiEnableLog を定義します。エンコーディング中立のエイリアスと、エンコーディング中立ではないコードを混在させて使用すると、不一致が生じてコンパイルエラーまたは実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiEnableLogA(
DWORD dwLogMode,
LPCSTR szLogFile, // optional
DWORD dwLogAttributes
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiEnableLogA(
uint dwLogMode, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string szLogFile, // LPCSTR optional
uint dwLogAttributes // DWORD
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiEnableLogA(
dwLogMode As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> szLogFile As String, ' LPCSTR optional
dwLogAttributes As UInteger ' DWORD
) As UInteger
End Function' dwLogMode : DWORD
' szLogFile : LPCSTR optional
' dwLogAttributes : DWORD
Declare PtrSafe Function MsiEnableLogA Lib "msi" ( _
ByVal dwLogMode As Long, _
ByVal szLogFile As String, _
ByVal dwLogAttributes As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiEnableLogA = ctypes.windll.msi.MsiEnableLogA
MsiEnableLogA.restype = wintypes.DWORD
MsiEnableLogA.argtypes = [
wintypes.DWORD, # dwLogMode : DWORD
wintypes.LPCSTR, # szLogFile : LPCSTR optional
wintypes.DWORD, # dwLogAttributes : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiEnableLogA = Fiddle::Function.new(
lib['MsiEnableLogA'],
[
-Fiddle::TYPE_INT, # dwLogMode : DWORD
Fiddle::TYPE_VOIDP, # szLogFile : LPCSTR optional
-Fiddle::TYPE_INT, # dwLogAttributes : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiEnableLogA(
dwLogMode: u32, // DWORD
szLogFile: *const u8, // LPCSTR optional
dwLogAttributes: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiEnableLogA(uint dwLogMode, [MarshalAs(UnmanagedType.LPStr)] string szLogFile, uint dwLogAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiEnableLogA' -Namespace Win32 -PassThru
# $api::MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes)#uselib "msi.dll"
#func global MsiEnableLogA "MsiEnableLogA" sptr, sptr, sptr
; MsiEnableLogA dwLogMode, szLogFile, dwLogAttributes ; 戻り値は stat
; dwLogMode : DWORD -> "sptr"
; szLogFile : LPCSTR optional -> "sptr"
; dwLogAttributes : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiEnableLogA "MsiEnableLogA" int, str, int
; res = MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes)
; dwLogMode : DWORD -> "int"
; szLogFile : LPCSTR optional -> "str"
; dwLogAttributes : DWORD -> "int"; DWORD MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD dwLogAttributes)
#uselib "msi.dll"
#cfunc global MsiEnableLogA "MsiEnableLogA" int, str, int
; res = MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes)
; dwLogMode : DWORD -> "int"
; szLogFile : LPCSTR optional -> "str"
; dwLogAttributes : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiEnableLogA = msi.NewProc("MsiEnableLogA")
)
// dwLogMode (DWORD), szLogFile (LPCSTR optional), dwLogAttributes (DWORD)
r1, _, err := procMsiEnableLogA.Call(
uintptr(dwLogMode),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szLogFile))),
uintptr(dwLogAttributes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiEnableLogA(
dwLogMode: DWORD; // DWORD
szLogFile: PAnsiChar; // LPCSTR optional
dwLogAttributes: DWORD // DWORD
): DWORD; stdcall;
external 'msi.dll' name 'MsiEnableLogA';result := DllCall("msi\MsiEnableLogA"
, "UInt", dwLogMode ; DWORD
, "AStr", szLogFile ; LPCSTR optional
, "UInt", dwLogAttributes ; DWORD
, "UInt") ; return: DWORD●MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes) = DLL("msi.dll", "dword MsiEnableLogA(dword, char*, dword)")
# 呼び出し: MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes)
# dwLogMode : DWORD -> "dword"
# szLogFile : LPCSTR optional -> "char*"
# dwLogAttributes : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiEnableLogA(
dwLogMode: u32, // DWORD
szLogFile: [*c]const u8, // LPCSTR optional
dwLogAttributes: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc MsiEnableLogA(
dwLogMode: uint32, # DWORD
szLogFile: cstring, # LPCSTR optional
dwLogAttributes: uint32 # DWORD
): uint32 {.importc: "MsiEnableLogA", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiEnableLogA(
uint dwLogMode, // DWORD
const(char)* szLogFile, // LPCSTR optional
uint dwLogAttributes // DWORD
);ccall((:MsiEnableLogA, "msi.dll"), stdcall, UInt32,
(UInt32, Cstring, UInt32),
dwLogMode, szLogFile, dwLogAttributes)
# dwLogMode : DWORD -> UInt32
# szLogFile : LPCSTR optional -> Cstring
# dwLogAttributes : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiEnableLogA(
uint32_t dwLogMode,
const char* szLogFile,
uint32_t dwLogAttributes);
]]
local msi = ffi.load("msi")
-- msi.MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes)
-- dwLogMode : DWORD
-- szLogFile : LPCSTR optional
-- dwLogAttributes : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiEnableLogA = lib.func('__stdcall', 'MsiEnableLogA', 'uint32_t', ['uint32_t', 'str', 'uint32_t']);
// MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes)
// dwLogMode : DWORD -> 'uint32_t'
// szLogFile : LPCSTR optional -> 'str'
// dwLogAttributes : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiEnableLogA: { parameters: ["u32", "buffer", "u32"], result: "u32" },
});
// lib.symbols.MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes)
// dwLogMode : DWORD -> "u32"
// szLogFile : LPCSTR optional -> "buffer"
// dwLogAttributes : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiEnableLogA(
uint32_t dwLogMode,
const char* szLogFile,
uint32_t dwLogAttributes);
C, "msi.dll");
// $ffi->MsiEnableLogA(dwLogMode, szLogFile, dwLogAttributes);
// dwLogMode : DWORD
// szLogFile : LPCSTR optional
// dwLogAttributes : 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.ASCII_OPTIONS);
int MsiEnableLogA(
int dwLogMode, // DWORD
String szLogFile, // LPCSTR optional
int dwLogAttributes // DWORD
);
}@[Link("msi")]
lib Libmsi
fun MsiEnableLogA = MsiEnableLogA(
dwLogMode : UInt32, # DWORD
szLogFile : UInt8*, # LPCSTR optional
dwLogAttributes : 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 MsiEnableLogANative = Uint32 Function(Uint32, Pointer<Utf8>, Uint32);
typedef MsiEnableLogADart = int Function(int, Pointer<Utf8>, int);
final MsiEnableLogA = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiEnableLogANative, MsiEnableLogADart>('MsiEnableLogA');
// dwLogMode : DWORD -> Uint32
// szLogFile : LPCSTR optional -> Pointer<Utf8>
// dwLogAttributes : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiEnableLogA(
dwLogMode: DWORD; // DWORD
szLogFile: PAnsiChar; // LPCSTR optional
dwLogAttributes: DWORD // DWORD
): DWORD; stdcall;
external 'msi.dll' name 'MsiEnableLogA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiEnableLogA"
c_MsiEnableLogA :: Word32 -> CString -> Word32 -> IO Word32
-- dwLogMode : DWORD -> Word32
-- szLogFile : LPCSTR optional -> CString
-- dwLogAttributes : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msienableloga =
foreign "MsiEnableLogA"
(uint32_t @-> string @-> uint32_t @-> returning uint32_t)
(* dwLogMode : DWORD -> uint32_t *)
(* szLogFile : LPCSTR optional -> string *)
(* dwLogAttributes : 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 ("MsiEnableLogA" msi-enable-log-a :convention :stdcall) :uint32
(dw-log-mode :uint32) ; DWORD
(sz-log-file :string) ; LPCSTR optional
(dw-log-attributes :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiEnableLogA = Win32::API::More->new('msi',
'DWORD MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD dwLogAttributes)');
# my $ret = $MsiEnableLogA->Call($dwLogMode, $szLogFile, $dwLogAttributes);
# dwLogMode : DWORD -> DWORD
# szLogFile : LPCSTR optional -> LPCSTR
# dwLogAttributes : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f MsiEnableLogW (Unicode版) — インストーラのログ出力を有効化する(Unicode版)。