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

SQLGetInfoW

関数
ドライバやデータソースの一般情報を取得する(Unicode)。
DLLODBC32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

SHORT SQLGetInfoW(
    void* hdbc,
    WORD fInfoType,
    void* rgbInfoValue,   // optional
    SHORT cbInfoValueMax,
    SHORT* pcbInfoValue   // optional
);

パラメーター

名前方向
hdbcvoid*inout
fInfoTypeWORDin
rgbInfoValuevoid*outoptional
cbInfoValueMaxSHORTin
pcbInfoValueSHORT*outoptional

戻り値の型: SHORT

各言語での呼び出し定義

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

SHORT SQLGetInfoW(
    void* hdbc,
    WORD fInfoType,
    void* rgbInfoValue,   // optional
    SHORT cbInfoValueMax,
    SHORT* pcbInfoValue   // optional
);
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLGetInfoW(
    IntPtr hdbc,   // void* in/out
    ushort fInfoType,   // WORD
    IntPtr rgbInfoValue,   // void* optional, out
    short cbInfoValueMax,   // SHORT
    IntPtr pcbInfoValue   // SHORT* optional, out
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLGetInfoW(
    hdbc As IntPtr,   ' void* in/out
    fInfoType As UShort,   ' WORD
    rgbInfoValue As IntPtr,   ' void* optional, out
    cbInfoValueMax As Short,   ' SHORT
    pcbInfoValue As IntPtr   ' SHORT* optional, out
) As Short
End Function
' hdbc : void* in/out
' fInfoType : WORD
' rgbInfoValue : void* optional, out
' cbInfoValueMax : SHORT
' pcbInfoValue : SHORT* optional, out
Declare PtrSafe Function SQLGetInfoW Lib "odbc32" ( _
    ByVal hdbc As LongPtr, _
    ByVal fInfoType As Integer, _
    ByVal rgbInfoValue As LongPtr, _
    ByVal cbInfoValueMax As Integer, _
    ByVal pcbInfoValue As LongPtr) As Integer
' 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

SQLGetInfoW = ctypes.windll.odbc32.SQLGetInfoW
SQLGetInfoW.restype = ctypes.c_short
SQLGetInfoW.argtypes = [
    ctypes.POINTER(None),  # hdbc : void* in/out
    ctypes.c_ushort,  # fInfoType : WORD
    ctypes.POINTER(None),  # rgbInfoValue : void* optional, out
    ctypes.c_short,  # cbInfoValueMax : SHORT
    ctypes.POINTER(ctypes.c_short),  # pcbInfoValue : SHORT* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLGetInfoW = Fiddle::Function.new(
  lib['SQLGetInfoW'],
  [
    Fiddle::TYPE_VOIDP,  # hdbc : void* in/out
    -Fiddle::TYPE_SHORT,  # fInfoType : WORD
    Fiddle::TYPE_VOIDP,  # rgbInfoValue : void* optional, out
    Fiddle::TYPE_SHORT,  # cbInfoValueMax : SHORT
    Fiddle::TYPE_VOIDP,  # pcbInfoValue : SHORT* optional, out
  ],
  Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "odbc32")]
extern "system" {
    fn SQLGetInfoW(
        hdbc: *mut (),  // void* in/out
        fInfoType: u16,  // WORD
        rgbInfoValue: *mut (),  // void* optional, out
        cbInfoValueMax: i16,  // SHORT
        pcbInfoValue: *mut i16  // SHORT* optional, out
    ) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode)]
public static extern short SQLGetInfoW(IntPtr hdbc, ushort fInfoType, IntPtr rgbInfoValue, short cbInfoValueMax, IntPtr pcbInfoValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetInfoW' -Namespace Win32 -PassThru
# $api::SQLGetInfoW(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue)
#uselib "ODBC32.dll"
#func global SQLGetInfoW "SQLGetInfoW" wptr, wptr, wptr, wptr, wptr
; SQLGetInfoW hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, varptr(pcbInfoValue)   ; 戻り値は stat
; hdbc : void* in/out -> "wptr"
; fInfoType : WORD -> "wptr"
; rgbInfoValue : void* optional, out -> "wptr"
; cbInfoValueMax : SHORT -> "wptr"
; pcbInfoValue : SHORT* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLGetInfoW "SQLGetInfoW" sptr, int, sptr, int, var
; res = SQLGetInfoW(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue)
; hdbc : void* in/out -> "sptr"
; fInfoType : WORD -> "int"
; rgbInfoValue : void* optional, out -> "sptr"
; cbInfoValueMax : SHORT -> "int"
; pcbInfoValue : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLGetInfoW(void* hdbc, WORD fInfoType, void* rgbInfoValue, SHORT cbInfoValueMax, SHORT* pcbInfoValue)
#uselib "ODBC32.dll"
#cfunc global SQLGetInfoW "SQLGetInfoW" intptr, int, intptr, int, var
; res = SQLGetInfoW(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue)
; hdbc : void* in/out -> "intptr"
; fInfoType : WORD -> "int"
; rgbInfoValue : void* optional, out -> "intptr"
; cbInfoValueMax : SHORT -> "int"
; pcbInfoValue : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLGetInfoW = odbc32.NewProc("SQLGetInfoW")
)

// hdbc (void* in/out), fInfoType (WORD), rgbInfoValue (void* optional, out), cbInfoValueMax (SHORT), pcbInfoValue (SHORT* optional, out)
r1, _, err := procSQLGetInfoW.Call(
	uintptr(hdbc),
	uintptr(fInfoType),
	uintptr(rgbInfoValue),
	uintptr(cbInfoValueMax),
	uintptr(pcbInfoValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLGetInfoW(
  hdbc: Pointer;   // void* in/out
  fInfoType: Word;   // WORD
  rgbInfoValue: Pointer;   // void* optional, out
  cbInfoValueMax: Smallint;   // SHORT
  pcbInfoValue: Pointer   // SHORT* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLGetInfoW';
result := DllCall("ODBC32\SQLGetInfoW"
    , "Ptr", hdbc   ; void* in/out
    , "UShort", fInfoType   ; WORD
    , "Ptr", rgbInfoValue   ; void* optional, out
    , "Short", cbInfoValueMax   ; SHORT
    , "Ptr", pcbInfoValue   ; SHORT* optional, out
    , "Short")   ; return: SHORT
●SQLGetInfoW(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue) = DLL("ODBC32.dll", "int SQLGetInfoW(void*, int, void*, int, void*)")
# 呼び出し: SQLGetInfoW(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue)
# hdbc : void* in/out -> "void*"
# fInfoType : WORD -> "int"
# rgbInfoValue : void* optional, out -> "void*"
# cbInfoValueMax : SHORT -> "int"
# pcbInfoValue : SHORT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。