ホーム › System.ApplicationInstallationAndServicing › MsiGetDatabaseState
MsiGetDatabaseState
関数データベースが読み取り専用か書き込み可能かの状態を取得する。
シグネチャ
// msi.dll
#include <windows.h>
MSIDBSTATE MsiGetDatabaseState(
MSIHANDLE hDatabase
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hDatabase | MSIHANDLE | in | MsiOpenDatabase から取得したデータベースへのハンドル。 |
戻り値の型: MSIDBSTATE
公式ドキュメント
MsiGetDatabaseState 関数は、データベースの状態を返します。
戻り値
この関数は MSIDBSTATE を返します。
解説(Remarks)
MsiGetDatabaseState 関数は、データベースの更新状態を返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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>
MSIDBSTATE MsiGetDatabaseState(
MSIHANDLE hDatabase
);[DllImport("msi.dll", ExactSpelling = true)]
static extern int MsiGetDatabaseState(
uint hDatabase // MSIHANDLE
);<DllImport("msi.dll", ExactSpelling:=True)>
Public Shared Function MsiGetDatabaseState(
hDatabase As UInteger ' MSIHANDLE
) As Integer
End Function' hDatabase : MSIHANDLE
Declare PtrSafe Function MsiGetDatabaseState Lib "msi" ( _
ByVal hDatabase As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiGetDatabaseState = ctypes.windll.msi.MsiGetDatabaseState
MsiGetDatabaseState.restype = ctypes.c_int
MsiGetDatabaseState.argtypes = [
wintypes.DWORD, # hDatabase : MSIHANDLE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiGetDatabaseState = Fiddle::Function.new(
lib['MsiGetDatabaseState'],
[
-Fiddle::TYPE_INT, # hDatabase : MSIHANDLE
],
Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiGetDatabaseState(
hDatabase: u32 // MSIHANDLE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll")]
public static extern int MsiGetDatabaseState(uint hDatabase);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetDatabaseState' -Namespace Win32 -PassThru
# $api::MsiGetDatabaseState(hDatabase)#uselib "msi.dll"
#func global MsiGetDatabaseState "MsiGetDatabaseState" sptr
; MsiGetDatabaseState hDatabase ; 戻り値は stat
; hDatabase : MSIHANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiGetDatabaseState "MsiGetDatabaseState" int
; res = MsiGetDatabaseState(hDatabase)
; hDatabase : MSIHANDLE -> "int"; MSIDBSTATE MsiGetDatabaseState(MSIHANDLE hDatabase)
#uselib "msi.dll"
#cfunc global MsiGetDatabaseState "MsiGetDatabaseState" int
; res = MsiGetDatabaseState(hDatabase)
; hDatabase : MSIHANDLE -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiGetDatabaseState = msi.NewProc("MsiGetDatabaseState")
)
// hDatabase (MSIHANDLE)
r1, _, err := procMsiGetDatabaseState.Call(
uintptr(hDatabase),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // MSIDBSTATEfunction MsiGetDatabaseState(
hDatabase: DWORD // MSIHANDLE
): Integer; stdcall;
external 'msi.dll' name 'MsiGetDatabaseState';result := DllCall("msi\MsiGetDatabaseState"
, "UInt", hDatabase ; MSIHANDLE
, "Int") ; return: MSIDBSTATE●MsiGetDatabaseState(hDatabase) = DLL("msi.dll", "int MsiGetDatabaseState(dword)")
# 呼び出し: MsiGetDatabaseState(hDatabase)
# hDatabase : MSIHANDLE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiGetDatabaseState(
hDatabase: u32 // MSIHANDLE
) callconv(std.os.windows.WINAPI) i32;proc MsiGetDatabaseState(
hDatabase: uint32 # MSIHANDLE
): int32 {.importc: "MsiGetDatabaseState", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
int MsiGetDatabaseState(
uint hDatabase // MSIHANDLE
);ccall((:MsiGetDatabaseState, "msi.dll"), stdcall, Int32,
(UInt32,),
hDatabase)
# hDatabase : MSIHANDLE -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MsiGetDatabaseState(
uint32_t hDatabase);
]]
local msi = ffi.load("msi")
-- msi.MsiGetDatabaseState(hDatabase)
-- hDatabase : MSIHANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiGetDatabaseState = lib.func('__stdcall', 'MsiGetDatabaseState', 'int32_t', ['uint32_t']);
// MsiGetDatabaseState(hDatabase)
// hDatabase : MSIHANDLE -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiGetDatabaseState: { parameters: ["u32"], result: "i32" },
});
// lib.symbols.MsiGetDatabaseState(hDatabase)
// hDatabase : MSIHANDLE -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MsiGetDatabaseState(
uint32_t hDatabase);
C, "msi.dll");
// $ffi->MsiGetDatabaseState(hDatabase);
// hDatabase : 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 MsiGetDatabaseState(
int hDatabase // MSIHANDLE
);
}@[Link("msi")]
lib Libmsi
fun MsiGetDatabaseState = MsiGetDatabaseState(
hDatabase : UInt32 # MSIHANDLE
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiGetDatabaseStateNative = Int32 Function(Uint32);
typedef MsiGetDatabaseStateDart = int Function(int);
final MsiGetDatabaseState = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiGetDatabaseStateNative, MsiGetDatabaseStateDart>('MsiGetDatabaseState');
// hDatabase : MSIHANDLE -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiGetDatabaseState(
hDatabase: DWORD // MSIHANDLE
): Integer; stdcall;
external 'msi.dll' name 'MsiGetDatabaseState';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiGetDatabaseState"
c_MsiGetDatabaseState :: Word32 -> IO Int32
-- hDatabase : MSIHANDLE -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msigetdatabasestate =
foreign "MsiGetDatabaseState"
(uint32_t @-> returning int32_t)
(* hDatabase : 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 ("MsiGetDatabaseState" msi-get-database-state :convention :stdcall) :int32
(h-database :uint32)) ; MSIHANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiGetDatabaseState = Win32::API::More->new('msi',
'int MsiGetDatabaseState(DWORD hDatabase)');
# my $ret = $MsiGetDatabaseState->Call($hDatabase);
# hDatabase : MSIHANDLE -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型