ホーム › System.ApplicationInstallationAndServicing › MsiOpenDatabaseW
MsiOpenDatabaseW
関数インストールデータベースを指定の永続モードで開く。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiOpenDatabaseW(
LPCWSTR szDatabasePath,
LPCWSTR szPersist,
MSIHANDLE* phDatabase
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szDatabasePath | LPCWSTR | in |
| szPersist | LPCWSTR | in |
| phDatabase | MSIHANDLE* | inout |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiOpenDatabaseW(
LPCWSTR szDatabasePath,
LPCWSTR szPersist,
MSIHANDLE* phDatabase
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiOpenDatabaseW(
[MarshalAs(UnmanagedType.LPWStr)] string szDatabasePath, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szPersist, // LPCWSTR
ref uint phDatabase // MSIHANDLE* in/out
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiOpenDatabaseW(
<MarshalAs(UnmanagedType.LPWStr)> szDatabasePath As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szPersist As String, ' LPCWSTR
ByRef phDatabase As UInteger ' MSIHANDLE* in/out
) As UInteger
End Function' szDatabasePath : LPCWSTR
' szPersist : LPCWSTR
' phDatabase : MSIHANDLE* in/out
Declare PtrSafe Function MsiOpenDatabaseW Lib "msi" ( _
ByVal szDatabasePath As LongPtr, _
ByVal szPersist As LongPtr, _
ByRef phDatabase 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
MsiOpenDatabaseW = ctypes.windll.msi.MsiOpenDatabaseW
MsiOpenDatabaseW.restype = wintypes.DWORD
MsiOpenDatabaseW.argtypes = [
wintypes.LPCWSTR, # szDatabasePath : LPCWSTR
wintypes.LPCWSTR, # szPersist : LPCWSTR
ctypes.c_void_p, # phDatabase : MSIHANDLE* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiOpenDatabaseW = Fiddle::Function.new(
lib['MsiOpenDatabaseW'],
[
Fiddle::TYPE_VOIDP, # szDatabasePath : LPCWSTR
Fiddle::TYPE_VOIDP, # szPersist : LPCWSTR
Fiddle::TYPE_VOIDP, # phDatabase : MSIHANDLE* in/out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiOpenDatabaseW(
szDatabasePath: *const u16, // LPCWSTR
szPersist: *const u16, // LPCWSTR
phDatabase: *mut u32 // MSIHANDLE* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiOpenDatabaseW([MarshalAs(UnmanagedType.LPWStr)] string szDatabasePath, [MarshalAs(UnmanagedType.LPWStr)] string szPersist, ref uint phDatabase);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiOpenDatabaseW' -Namespace Win32 -PassThru
# $api::MsiOpenDatabaseW(szDatabasePath, szPersist, phDatabase)#uselib "msi.dll"
#func global MsiOpenDatabaseW "MsiOpenDatabaseW" wptr, wptr, wptr
; MsiOpenDatabaseW szDatabasePath, szPersist, phDatabase ; 戻り値は stat
; szDatabasePath : LPCWSTR -> "wptr"
; szPersist : LPCWSTR -> "wptr"
; phDatabase : MSIHANDLE* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiOpenDatabaseW "MsiOpenDatabaseW" wstr, wstr, int
; res = MsiOpenDatabaseW(szDatabasePath, szPersist, phDatabase)
; szDatabasePath : LPCWSTR -> "wstr"
; szPersist : LPCWSTR -> "wstr"
; phDatabase : MSIHANDLE* in/out -> "int"; DWORD MsiOpenDatabaseW(LPCWSTR szDatabasePath, LPCWSTR szPersist, MSIHANDLE* phDatabase)
#uselib "msi.dll"
#cfunc global MsiOpenDatabaseW "MsiOpenDatabaseW" wstr, wstr, int
; res = MsiOpenDatabaseW(szDatabasePath, szPersist, phDatabase)
; szDatabasePath : LPCWSTR -> "wstr"
; szPersist : LPCWSTR -> "wstr"
; phDatabase : MSIHANDLE* in/out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiOpenDatabaseW = msi.NewProc("MsiOpenDatabaseW")
)
// szDatabasePath (LPCWSTR), szPersist (LPCWSTR), phDatabase (MSIHANDLE* in/out)
r1, _, err := procMsiOpenDatabaseW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szDatabasePath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szPersist))),
uintptr(phDatabase),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiOpenDatabaseW(
szDatabasePath: PWideChar; // LPCWSTR
szPersist: PWideChar; // LPCWSTR
phDatabase: Pointer // MSIHANDLE* in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiOpenDatabaseW';result := DllCall("msi\MsiOpenDatabaseW"
, "WStr", szDatabasePath ; LPCWSTR
, "WStr", szPersist ; LPCWSTR
, "Ptr", phDatabase ; MSIHANDLE* in/out
, "UInt") ; return: DWORD●MsiOpenDatabaseW(szDatabasePath, szPersist, phDatabase) = DLL("msi.dll", "dword MsiOpenDatabaseW(char*, char*, void*)")
# 呼び出し: MsiOpenDatabaseW(szDatabasePath, szPersist, phDatabase)
# szDatabasePath : LPCWSTR -> "char*"
# szPersist : LPCWSTR -> "char*"
# phDatabase : MSIHANDLE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。