ホーム › System.Search › SQLGetInfo
SQLGetInfo
関数ドライバやデータソースの一般情報を取得する。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetInfo(
void* ConnectionHandle,
WORD InfoType,
void* InfoValue, // optional
SHORT BufferLength,
SHORT* StringLengthPtr // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ConnectionHandle | void* | inout |
| InfoType | WORD | in |
| InfoValue | void* | outoptional |
| BufferLength | SHORT | in |
| StringLengthPtr | SHORT* | outoptional |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetInfo(
void* ConnectionHandle,
WORD InfoType,
void* InfoValue, // optional
SHORT BufferLength,
SHORT* StringLengthPtr // optional
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLGetInfo(
IntPtr ConnectionHandle, // void* in/out
ushort InfoType, // WORD
IntPtr InfoValue, // void* optional, out
short BufferLength, // SHORT
IntPtr StringLengthPtr // SHORT* optional, out
);<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLGetInfo(
ConnectionHandle As IntPtr, ' void* in/out
InfoType As UShort, ' WORD
InfoValue As IntPtr, ' void* optional, out
BufferLength As Short, ' SHORT
StringLengthPtr As IntPtr ' SHORT* optional, out
) As Short
End Function' ConnectionHandle : void* in/out
' InfoType : WORD
' InfoValue : void* optional, out
' BufferLength : SHORT
' StringLengthPtr : SHORT* optional, out
Declare PtrSafe Function SQLGetInfo Lib "odbc32" ( _
ByVal ConnectionHandle As LongPtr, _
ByVal InfoType As Integer, _
ByVal InfoValue As LongPtr, _
ByVal BufferLength As Integer, _
ByVal StringLengthPtr As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLGetInfo = ctypes.windll.odbc32.SQLGetInfo
SQLGetInfo.restype = ctypes.c_short
SQLGetInfo.argtypes = [
ctypes.POINTER(None), # ConnectionHandle : void* in/out
ctypes.c_ushort, # InfoType : WORD
ctypes.POINTER(None), # InfoValue : void* optional, out
ctypes.c_short, # BufferLength : SHORT
ctypes.POINTER(ctypes.c_short), # StringLengthPtr : SHORT* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLGetInfo = Fiddle::Function.new(
lib['SQLGetInfo'],
[
Fiddle::TYPE_VOIDP, # ConnectionHandle : void* in/out
-Fiddle::TYPE_SHORT, # InfoType : WORD
Fiddle::TYPE_VOIDP, # InfoValue : void* optional, out
Fiddle::TYPE_SHORT, # BufferLength : SHORT
Fiddle::TYPE_VOIDP, # StringLengthPtr : SHORT* optional, out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLGetInfo(
ConnectionHandle: *mut (), // void* in/out
InfoType: u16, // WORD
InfoValue: *mut (), // void* optional, out
BufferLength: i16, // SHORT
StringLengthPtr: *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 SQLGetInfo(IntPtr ConnectionHandle, ushort InfoType, IntPtr InfoValue, short BufferLength, IntPtr StringLengthPtr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetInfo' -Namespace Win32 -PassThru
# $api::SQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLengthPtr)#uselib "ODBC32.dll"
#func global SQLGetInfo "SQLGetInfo" sptr, sptr, sptr, sptr, sptr
; SQLGetInfo ConnectionHandle, InfoType, InfoValue, BufferLength, varptr(StringLengthPtr) ; 戻り値は stat
; ConnectionHandle : void* in/out -> "sptr"
; InfoType : WORD -> "sptr"
; InfoValue : void* optional, out -> "sptr"
; BufferLength : SHORT -> "sptr"
; StringLengthPtr : SHORT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLGetInfo "SQLGetInfo" sptr, int, sptr, int, var ; res = SQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLengthPtr) ; ConnectionHandle : void* in/out -> "sptr" ; InfoType : WORD -> "int" ; InfoValue : void* optional, out -> "sptr" ; BufferLength : SHORT -> "int" ; StringLengthPtr : SHORT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLGetInfo "SQLGetInfo" sptr, int, sptr, int, sptr ; res = SQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, varptr(StringLengthPtr)) ; ConnectionHandle : void* in/out -> "sptr" ; InfoType : WORD -> "int" ; InfoValue : void* optional, out -> "sptr" ; BufferLength : SHORT -> "int" ; StringLengthPtr : SHORT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLGetInfo(void* ConnectionHandle, WORD InfoType, void* InfoValue, SHORT BufferLength, SHORT* StringLengthPtr) #uselib "ODBC32.dll" #cfunc global SQLGetInfo "SQLGetInfo" intptr, int, intptr, int, var ; res = SQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLengthPtr) ; ConnectionHandle : void* in/out -> "intptr" ; InfoType : WORD -> "int" ; InfoValue : void* optional, out -> "intptr" ; BufferLength : SHORT -> "int" ; StringLengthPtr : SHORT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLGetInfo(void* ConnectionHandle, WORD InfoType, void* InfoValue, SHORT BufferLength, SHORT* StringLengthPtr) #uselib "ODBC32.dll" #cfunc global SQLGetInfo "SQLGetInfo" intptr, int, intptr, int, intptr ; res = SQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, varptr(StringLengthPtr)) ; ConnectionHandle : void* in/out -> "intptr" ; InfoType : WORD -> "int" ; InfoValue : void* optional, out -> "intptr" ; BufferLength : SHORT -> "int" ; StringLengthPtr : SHORT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLGetInfo = odbc32.NewProc("SQLGetInfo")
)
// ConnectionHandle (void* in/out), InfoType (WORD), InfoValue (void* optional, out), BufferLength (SHORT), StringLengthPtr (SHORT* optional, out)
r1, _, err := procSQLGetInfo.Call(
uintptr(ConnectionHandle),
uintptr(InfoType),
uintptr(InfoValue),
uintptr(BufferLength),
uintptr(StringLengthPtr),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLGetInfo(
ConnectionHandle: Pointer; // void* in/out
InfoType: Word; // WORD
InfoValue: Pointer; // void* optional, out
BufferLength: Smallint; // SHORT
StringLengthPtr: Pointer // SHORT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetInfo';result := DllCall("ODBC32\SQLGetInfo"
, "Ptr", ConnectionHandle ; void* in/out
, "UShort", InfoType ; WORD
, "Ptr", InfoValue ; void* optional, out
, "Short", BufferLength ; SHORT
, "Ptr", StringLengthPtr ; SHORT* optional, out
, "Short") ; return: SHORT●SQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLengthPtr) = DLL("ODBC32.dll", "int SQLGetInfo(void*, int, void*, int, void*)")
# 呼び出し: SQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLengthPtr)
# ConnectionHandle : void* in/out -> "void*"
# InfoType : WORD -> "int"
# InfoValue : void* optional, out -> "void*"
# BufferLength : SHORT -> "int"
# StringLengthPtr : SHORT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。