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

MsiDatabaseOpenViewW

関数
インストールデータベースに対するSQLクエリのビューを開く。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiDatabaseOpenViewW(
    MSIHANDLE hDatabase,
    LPCWSTR szQuery,
    MSIHANDLE* phView
);

パラメーター

名前方向
hDatabaseMSIHANDLEin
szQueryLPCWSTRin
phViewMSIHANDLE*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MsiDatabaseOpenViewW = ctypes.windll.msi.MsiDatabaseOpenViewW
MsiDatabaseOpenViewW.restype = wintypes.DWORD
MsiDatabaseOpenViewW.argtypes = [
    wintypes.DWORD,  # hDatabase : MSIHANDLE
    wintypes.LPCWSTR,  # szQuery : LPCWSTR
    ctypes.c_void_p,  # phView : MSIHANDLE* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiDatabaseOpenViewW = Fiddle::Function.new(
  lib['MsiDatabaseOpenViewW'],
  [
    -Fiddle::TYPE_INT,  # hDatabase : MSIHANDLE
    Fiddle::TYPE_VOIDP,  # szQuery : LPCWSTR
    Fiddle::TYPE_VOIDP,  # phView : MSIHANDLE* in/out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiDatabaseOpenViewW(
        hDatabase: u32,  // MSIHANDLE
        szQuery: *const u16,  // LPCWSTR
        phView: *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 MsiDatabaseOpenViewW(uint hDatabase, [MarshalAs(UnmanagedType.LPWStr)] string szQuery, ref uint phView);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiDatabaseOpenViewW' -Namespace Win32 -PassThru
# $api::MsiDatabaseOpenViewW(hDatabase, szQuery, phView)
#uselib "msi.dll"
#func global MsiDatabaseOpenViewW "MsiDatabaseOpenViewW" wptr, wptr, wptr
; MsiDatabaseOpenViewW hDatabase, szQuery, phView   ; 戻り値は stat
; hDatabase : MSIHANDLE -> "wptr"
; szQuery : LPCWSTR -> "wptr"
; phView : MSIHANDLE* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiDatabaseOpenViewW "MsiDatabaseOpenViewW" int, wstr, int
; res = MsiDatabaseOpenViewW(hDatabase, szQuery, phView)
; hDatabase : MSIHANDLE -> "int"
; szQuery : LPCWSTR -> "wstr"
; phView : MSIHANDLE* in/out -> "int"
; DWORD MsiDatabaseOpenViewW(MSIHANDLE hDatabase, LPCWSTR szQuery, MSIHANDLE* phView)
#uselib "msi.dll"
#cfunc global MsiDatabaseOpenViewW "MsiDatabaseOpenViewW" int, wstr, int
; res = MsiDatabaseOpenViewW(hDatabase, szQuery, phView)
; hDatabase : MSIHANDLE -> "int"
; szQuery : LPCWSTR -> "wstr"
; phView : MSIHANDLE* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiDatabaseOpenViewW = msi.NewProc("MsiDatabaseOpenViewW")
)

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