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

MsiDatabaseExportW

関数
データベースの指定テーブルをテキストアーカイブにエクスポートする。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiDatabaseExportW(
    MSIHANDLE hDatabase,
    LPCWSTR szTableName,
    LPCWSTR szFolderPath,
    LPCWSTR szFileName
);

パラメーター

名前方向
hDatabaseMSIHANDLEin
szTableNameLPCWSTRin
szFolderPathLPCWSTRin
szFileNameLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiDatabaseExportW(
    MSIHANDLE hDatabase,
    LPCWSTR szTableName,
    LPCWSTR szFolderPath,
    LPCWSTR szFileName
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiDatabaseExportW(
    uint hDatabase,   // MSIHANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string szTableName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szFolderPath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szFileName   // LPCWSTR
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiDatabaseExportW(
    hDatabase As UInteger,   ' MSIHANDLE
    <MarshalAs(UnmanagedType.LPWStr)> szTableName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szFolderPath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szFileName As String   ' LPCWSTR
) As UInteger
End Function
' hDatabase : MSIHANDLE
' szTableName : LPCWSTR
' szFolderPath : LPCWSTR
' szFileName : LPCWSTR
Declare PtrSafe Function MsiDatabaseExportW Lib "msi" ( _
    ByVal hDatabase As Long, _
    ByVal szTableName As LongPtr, _
    ByVal szFolderPath As LongPtr, _
    ByVal szFileName As LongPtr) 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

MsiDatabaseExportW = ctypes.windll.msi.MsiDatabaseExportW
MsiDatabaseExportW.restype = wintypes.DWORD
MsiDatabaseExportW.argtypes = [
    wintypes.DWORD,  # hDatabase : MSIHANDLE
    wintypes.LPCWSTR,  # szTableName : LPCWSTR
    wintypes.LPCWSTR,  # szFolderPath : LPCWSTR
    wintypes.LPCWSTR,  # szFileName : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiDatabaseExportW = msi.NewProc("MsiDatabaseExportW")
)

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