ホーム › System.ApplicationInstallationAndServicing › MsiViewExecute
MsiViewExecute
関数パラメータレコードを与えてビューのクエリを実行する。
シグネチャ
// msi.dll
#include <windows.h>
DWORD MsiViewExecute(
MSIHANDLE hView,
MSIHANDLE hRecord
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hView | MSIHANDLE | in | クエリを実行するビューへのハンドルです。 |
| hRecord | MSIHANDLE | in | パラメーターを指定するレコードへのハンドルです。このパラメーターには、SQL クエリ内のパラメータートークンを置き換える値が含まれます。省略可能であり、hRecord はゼロにできます。構文については、 SQL Syntax を参照してください。 |
戻り値の型: DWORD
公式ドキュメント
MsiViewExecute 関数は SQL ビュークエリを実行し、必要なパラメーターを指定します。
戻り値
メモリ不足の状況では、この関数が STATUS_NO_MEMORY 例外を発生させる場合があることに注意してください。
解説(Remarks)
MsiViewExecute 関数は、 MsiViewFetch を呼び出す前に呼び出す必要があります。
SQL クエリがパラメーターマーカー (?) で値を指定する場合、すべての置換値を正確な順序かつ互換性のあるデータ型で含むレコードを指定する必要があります。INSERT クエリおよび UPDATE クエリで使用する場合、すべてのパラメーター化された値は、パラメーター化されていないすべての値より前に置く必要があります。
たとえば、以下のクエリは有効です。
UPDATE {table-list} SET {column}= ? , {column}= {constant}
INSERT INTO {table} ({column-list}) VALUES (?, {constant-list})
ただし、以下のクエリは無効です。
UPDATE {table-list} SET {column}= {constant}, {column}=?
INSERT INTO {table} ({column-list}) VALUES ({constant-list}, ? )
関数が失敗した場合は、MsiGetLastErrorRecord を使用して拡張エラー情報を取得できます。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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
#include <windows.h>
DWORD MsiViewExecute(
MSIHANDLE hView,
MSIHANDLE hRecord
);[DllImport("msi.dll", ExactSpelling = true)]
static extern uint MsiViewExecute(
uint hView, // MSIHANDLE
uint hRecord // MSIHANDLE
);<DllImport("msi.dll", ExactSpelling:=True)>
Public Shared Function MsiViewExecute(
hView As UInteger, ' MSIHANDLE
hRecord As UInteger ' MSIHANDLE
) As UInteger
End Function' hView : MSIHANDLE
' hRecord : MSIHANDLE
Declare PtrSafe Function MsiViewExecute Lib "msi" ( _
ByVal hView As Long, _
ByVal hRecord As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiViewExecute = ctypes.windll.msi.MsiViewExecute
MsiViewExecute.restype = wintypes.DWORD
MsiViewExecute.argtypes = [
wintypes.DWORD, # hView : MSIHANDLE
wintypes.DWORD, # hRecord : MSIHANDLE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiViewExecute = Fiddle::Function.new(
lib['MsiViewExecute'],
[
-Fiddle::TYPE_INT, # hView : MSIHANDLE
-Fiddle::TYPE_INT, # hRecord : MSIHANDLE
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiViewExecute(
hView: u32, // MSIHANDLE
hRecord: u32 // MSIHANDLE
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll")]
public static extern uint MsiViewExecute(uint hView, uint hRecord);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiViewExecute' -Namespace Win32 -PassThru
# $api::MsiViewExecute(hView, hRecord)#uselib "msi.dll"
#func global MsiViewExecute "MsiViewExecute" sptr, sptr
; MsiViewExecute hView, hRecord ; 戻り値は stat
; hView : MSIHANDLE -> "sptr"
; hRecord : MSIHANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiViewExecute "MsiViewExecute" int, int
; res = MsiViewExecute(hView, hRecord)
; hView : MSIHANDLE -> "int"
; hRecord : MSIHANDLE -> "int"; DWORD MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRecord)
#uselib "msi.dll"
#cfunc global MsiViewExecute "MsiViewExecute" int, int
; res = MsiViewExecute(hView, hRecord)
; hView : MSIHANDLE -> "int"
; hRecord : MSIHANDLE -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiViewExecute = msi.NewProc("MsiViewExecute")
)
// hView (MSIHANDLE), hRecord (MSIHANDLE)
r1, _, err := procMsiViewExecute.Call(
uintptr(hView),
uintptr(hRecord),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiViewExecute(
hView: DWORD; // MSIHANDLE
hRecord: DWORD // MSIHANDLE
): DWORD; stdcall;
external 'msi.dll' name 'MsiViewExecute';result := DllCall("msi\MsiViewExecute"
, "UInt", hView ; MSIHANDLE
, "UInt", hRecord ; MSIHANDLE
, "UInt") ; return: DWORD●MsiViewExecute(hView, hRecord) = DLL("msi.dll", "dword MsiViewExecute(dword, dword)")
# 呼び出し: MsiViewExecute(hView, hRecord)
# hView : MSIHANDLE -> "dword"
# hRecord : MSIHANDLE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiViewExecute(
hView: u32, // MSIHANDLE
hRecord: u32 // MSIHANDLE
) callconv(std.os.windows.WINAPI) u32;proc MsiViewExecute(
hView: uint32, # MSIHANDLE
hRecord: uint32 # MSIHANDLE
): uint32 {.importc: "MsiViewExecute", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiViewExecute(
uint hView, // MSIHANDLE
uint hRecord // MSIHANDLE
);ccall((:MsiViewExecute, "msi.dll"), stdcall, UInt32,
(UInt32, UInt32),
hView, hRecord)
# hView : MSIHANDLE -> UInt32
# hRecord : MSIHANDLE -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiViewExecute(
uint32_t hView,
uint32_t hRecord);
]]
local msi = ffi.load("msi")
-- msi.MsiViewExecute(hView, hRecord)
-- hView : MSIHANDLE
-- hRecord : MSIHANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiViewExecute = lib.func('__stdcall', 'MsiViewExecute', 'uint32_t', ['uint32_t', 'uint32_t']);
// MsiViewExecute(hView, hRecord)
// hView : MSIHANDLE -> 'uint32_t'
// hRecord : MSIHANDLE -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiViewExecute: { parameters: ["u32", "u32"], result: "u32" },
});
// lib.symbols.MsiViewExecute(hView, hRecord)
// hView : MSIHANDLE -> "u32"
// hRecord : MSIHANDLE -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiViewExecute(
uint32_t hView,
uint32_t hRecord);
C, "msi.dll");
// $ffi->MsiViewExecute(hView, hRecord);
// hView : MSIHANDLE
// hRecord : MSIHANDLE
// 構造体/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);
int MsiViewExecute(
int hView, // MSIHANDLE
int hRecord // MSIHANDLE
);
}@[Link("msi")]
lib Libmsi
fun MsiViewExecute = MsiViewExecute(
hView : UInt32, # MSIHANDLE
hRecord : UInt32 # MSIHANDLE
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiViewExecuteNative = Uint32 Function(Uint32, Uint32);
typedef MsiViewExecuteDart = int Function(int, int);
final MsiViewExecute = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiViewExecuteNative, MsiViewExecuteDart>('MsiViewExecute');
// hView : MSIHANDLE -> Uint32
// hRecord : MSIHANDLE -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiViewExecute(
hView: DWORD; // MSIHANDLE
hRecord: DWORD // MSIHANDLE
): DWORD; stdcall;
external 'msi.dll' name 'MsiViewExecute';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiViewExecute"
c_MsiViewExecute :: Word32 -> Word32 -> IO Word32
-- hView : MSIHANDLE -> Word32
-- hRecord : MSIHANDLE -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msiviewexecute =
foreign "MsiViewExecute"
(uint32_t @-> uint32_t @-> returning uint32_t)
(* hView : MSIHANDLE -> uint32_t *)
(* hRecord : MSIHANDLE -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiViewExecute" msi-view-execute :convention :stdcall) :uint32
(h-view :uint32) ; MSIHANDLE
(h-record :uint32)) ; MSIHANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiViewExecute = Win32::API::More->new('msi',
'DWORD MsiViewExecute(DWORD hView, DWORD hRecord)');
# my $ret = $MsiViewExecute->Call($hView, $hRecord);
# hView : MSIHANDLE -> DWORD
# hRecord : MSIHANDLE -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。