ホーム › System.Search › SQLGetInfoA
SQLGetInfoA
関数ODBCドライバやデータソースに関する情報を取得する。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetInfoA(
void* hdbc,
WORD fInfoType,
void* rgbInfoValue, // optional
SHORT cbInfoValueMax,
SHORT* pcbInfoValue // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdbc | void* | inout |
| fInfoType | WORD | in |
| rgbInfoValue | void* | outoptional |
| cbInfoValueMax | SHORT | in |
| pcbInfoValue | SHORT* | outoptional |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetInfoA(
void* hdbc,
WORD fInfoType,
void* rgbInfoValue, // optional
SHORT cbInfoValueMax,
SHORT* pcbInfoValue // optional
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLGetInfoA(
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.Ansi, ExactSpelling:=True)>
Public Shared Function SQLGetInfoA(
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 SQLGetInfoA Lib "odbc32" ( _
ByVal hdbc As LongPtr, _
ByVal fInfoType As Integer, _
ByVal rgbInfoValue As LongPtr, _
ByVal cbInfoValueMax As Integer, _
ByVal pcbInfoValue As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLGetInfoA = ctypes.windll.odbc32.SQLGetInfoA
SQLGetInfoA.restype = ctypes.c_short
SQLGetInfoA.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')
SQLGetInfoA = Fiddle::Function.new(
lib['SQLGetInfoA'],
[
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)#[link(name = "odbc32")]
extern "system" {
fn SQLGetInfoA(
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.Ansi)]
public static extern short SQLGetInfoA(IntPtr hdbc, ushort fInfoType, IntPtr rgbInfoValue, short cbInfoValueMax, IntPtr pcbInfoValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetInfoA' -Namespace Win32 -PassThru
# $api::SQLGetInfoA(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue)#uselib "ODBC32.dll"
#func global SQLGetInfoA "SQLGetInfoA" sptr, sptr, sptr, sptr, sptr
; SQLGetInfoA hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, varptr(pcbInfoValue) ; 戻り値は stat
; hdbc : void* in/out -> "sptr"
; fInfoType : WORD -> "sptr"
; rgbInfoValue : void* optional, out -> "sptr"
; cbInfoValueMax : SHORT -> "sptr"
; pcbInfoValue : SHORT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLGetInfoA "SQLGetInfoA" sptr, int, sptr, int, var ; res = SQLGetInfoA(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 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLGetInfoA "SQLGetInfoA" sptr, int, sptr, int, sptr ; res = SQLGetInfoA(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, varptr(pcbInfoValue)) ; hdbc : void* in/out -> "sptr" ; fInfoType : WORD -> "int" ; rgbInfoValue : void* optional, out -> "sptr" ; cbInfoValueMax : SHORT -> "int" ; pcbInfoValue : SHORT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLGetInfoA(void* hdbc, WORD fInfoType, void* rgbInfoValue, SHORT cbInfoValueMax, SHORT* pcbInfoValue) #uselib "ODBC32.dll" #cfunc global SQLGetInfoA "SQLGetInfoA" intptr, int, intptr, int, var ; res = SQLGetInfoA(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 方式にも切替可。; SHORT SQLGetInfoA(void* hdbc, WORD fInfoType, void* rgbInfoValue, SHORT cbInfoValueMax, SHORT* pcbInfoValue) #uselib "ODBC32.dll" #cfunc global SQLGetInfoA "SQLGetInfoA" intptr, int, intptr, int, intptr ; res = SQLGetInfoA(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, varptr(pcbInfoValue)) ; hdbc : void* in/out -> "intptr" ; fInfoType : WORD -> "int" ; rgbInfoValue : void* optional, out -> "intptr" ; cbInfoValueMax : SHORT -> "int" ; pcbInfoValue : SHORT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLGetInfoA = odbc32.NewProc("SQLGetInfoA")
)
// hdbc (void* in/out), fInfoType (WORD), rgbInfoValue (void* optional, out), cbInfoValueMax (SHORT), pcbInfoValue (SHORT* optional, out)
r1, _, err := procSQLGetInfoA.Call(
uintptr(hdbc),
uintptr(fInfoType),
uintptr(rgbInfoValue),
uintptr(cbInfoValueMax),
uintptr(pcbInfoValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLGetInfoA(
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 'SQLGetInfoA';result := DllCall("ODBC32\SQLGetInfoA"
, "Ptr", hdbc ; void* in/out
, "UShort", fInfoType ; WORD
, "Ptr", rgbInfoValue ; void* optional, out
, "Short", cbInfoValueMax ; SHORT
, "Ptr", pcbInfoValue ; SHORT* optional, out
, "Short") ; return: SHORT●SQLGetInfoA(hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue) = DLL("ODBC32.dll", "int SQLGetInfoA(void*, int, void*, int, void*)")
# 呼び出し: SQLGetInfoA(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)。