ホーム › System.ApplicationInstallationAndServicing › MsiViewGetErrorW
MsiViewGetErrorW
関数ビュー操作で発生した検証エラーと該当カラム名を取得する。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
MSIDBERROR MsiViewGetErrorW(
MSIHANDLE hView,
LPWSTR szColumnNameBuffer, // optional
DWORD* pcchBuf // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hView | MSIHANDLE | in |
| szColumnNameBuffer | LPWSTR | outoptional |
| pcchBuf | DWORD* | inoutoptional |
戻り値の型: MSIDBERROR
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
MSIDBERROR MsiViewGetErrorW(
MSIHANDLE hView,
LPWSTR szColumnNameBuffer, // optional
DWORD* pcchBuf // optional
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int MsiViewGetErrorW(
uint hView, // MSIHANDLE
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szColumnNameBuffer, // LPWSTR optional, out
IntPtr pcchBuf // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiViewGetErrorW(
hView As UInteger, ' MSIHANDLE
<MarshalAs(UnmanagedType.LPWStr)> szColumnNameBuffer As System.Text.StringBuilder, ' LPWSTR optional, out
pcchBuf As IntPtr ' DWORD* optional, in/out
) As Integer
End Function' hView : MSIHANDLE
' szColumnNameBuffer : LPWSTR optional, out
' pcchBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiViewGetErrorW Lib "msi" ( _
ByVal hView As Long, _
ByVal szColumnNameBuffer As LongPtr, _
ByVal pcchBuf 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
MsiViewGetErrorW = ctypes.windll.msi.MsiViewGetErrorW
MsiViewGetErrorW.restype = ctypes.c_int
MsiViewGetErrorW.argtypes = [
wintypes.DWORD, # hView : MSIHANDLE
wintypes.LPWSTR, # szColumnNameBuffer : LPWSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchBuf : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiViewGetErrorW = Fiddle::Function.new(
lib['MsiViewGetErrorW'],
[
-Fiddle::TYPE_INT, # hView : MSIHANDLE
Fiddle::TYPE_VOIDP, # szColumnNameBuffer : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # pcchBuf : DWORD* optional, in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiViewGetErrorW(
hView: u32, // MSIHANDLE
szColumnNameBuffer: *mut u16, // LPWSTR optional, out
pcchBuf: *mut u32 // DWORD* optional, in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern int MsiViewGetErrorW(uint hView, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szColumnNameBuffer, IntPtr pcchBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiViewGetErrorW' -Namespace Win32 -PassThru
# $api::MsiViewGetErrorW(hView, szColumnNameBuffer, pcchBuf)#uselib "msi.dll"
#func global MsiViewGetErrorW "MsiViewGetErrorW" wptr, wptr, wptr
; MsiViewGetErrorW hView, varptr(szColumnNameBuffer), varptr(pcchBuf) ; 戻り値は stat
; hView : MSIHANDLE -> "wptr"
; szColumnNameBuffer : LPWSTR optional, out -> "wptr"
; pcchBuf : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiViewGetErrorW "MsiViewGetErrorW" int, var, var ; res = MsiViewGetErrorW(hView, szColumnNameBuffer, pcchBuf) ; hView : MSIHANDLE -> "int" ; szColumnNameBuffer : LPWSTR optional, out -> "var" ; pcchBuf : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiViewGetErrorW "MsiViewGetErrorW" int, sptr, sptr ; res = MsiViewGetErrorW(hView, varptr(szColumnNameBuffer), varptr(pcchBuf)) ; hView : MSIHANDLE -> "int" ; szColumnNameBuffer : LPWSTR optional, out -> "sptr" ; pcchBuf : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; MSIDBERROR MsiViewGetErrorW(MSIHANDLE hView, LPWSTR szColumnNameBuffer, DWORD* pcchBuf) #uselib "msi.dll" #cfunc global MsiViewGetErrorW "MsiViewGetErrorW" int, var, var ; res = MsiViewGetErrorW(hView, szColumnNameBuffer, pcchBuf) ; hView : MSIHANDLE -> "int" ; szColumnNameBuffer : LPWSTR optional, out -> "var" ; pcchBuf : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; MSIDBERROR MsiViewGetErrorW(MSIHANDLE hView, LPWSTR szColumnNameBuffer, DWORD* pcchBuf) #uselib "msi.dll" #cfunc global MsiViewGetErrorW "MsiViewGetErrorW" int, intptr, intptr ; res = MsiViewGetErrorW(hView, varptr(szColumnNameBuffer), varptr(pcchBuf)) ; hView : MSIHANDLE -> "int" ; szColumnNameBuffer : LPWSTR optional, out -> "intptr" ; pcchBuf : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiViewGetErrorW = msi.NewProc("MsiViewGetErrorW")
)
// hView (MSIHANDLE), szColumnNameBuffer (LPWSTR optional, out), pcchBuf (DWORD* optional, in/out)
r1, _, err := procMsiViewGetErrorW.Call(
uintptr(hView),
uintptr(szColumnNameBuffer),
uintptr(pcchBuf),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // MSIDBERRORfunction MsiViewGetErrorW(
hView: DWORD; // MSIHANDLE
szColumnNameBuffer: PWideChar; // LPWSTR optional, out
pcchBuf: Pointer // DWORD* optional, in/out
): Integer; stdcall;
external 'msi.dll' name 'MsiViewGetErrorW';result := DllCall("msi\MsiViewGetErrorW"
, "UInt", hView ; MSIHANDLE
, "Ptr", szColumnNameBuffer ; LPWSTR optional, out
, "Ptr", pcchBuf ; DWORD* optional, in/out
, "Int") ; return: MSIDBERROR●MsiViewGetErrorW(hView, szColumnNameBuffer, pcchBuf) = DLL("msi.dll", "int MsiViewGetErrorW(dword, char*, void*)")
# 呼び出し: MsiViewGetErrorW(hView, szColumnNameBuffer, pcchBuf)
# hView : MSIHANDLE -> "dword"
# szColumnNameBuffer : LPWSTR optional, out -> "char*"
# pcchBuf : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。