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

SQLGetConnectAttr

関数
接続属性の現在値を取得する。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLGetConnectAttr(
    void* ConnectionHandle,
    INT Attribute,
    void* Value,   // optional
    INT BufferLength,
    INT* StringLengthPtr   // optional
);

パラメーター

名前方向
ConnectionHandlevoid*inout
AttributeINTin
Valuevoid*outoptional
BufferLengthINTin
StringLengthPtrINT*outoptional

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLGetConnectAttr(
    void* ConnectionHandle,
    INT Attribute,
    void* Value,   // optional
    INT BufferLength,
    INT* StringLengthPtr   // optional
);
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLGetConnectAttr(
    IntPtr ConnectionHandle,   // void* in/out
    int Attribute,   // INT
    IntPtr Value,   // void* optional, out
    int BufferLength,   // INT
    IntPtr StringLengthPtr   // INT* optional, out
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLGetConnectAttr(
    ConnectionHandle As IntPtr,   ' void* in/out
    Attribute As Integer,   ' INT
    Value As IntPtr,   ' void* optional, out
    BufferLength As Integer,   ' INT
    StringLengthPtr As IntPtr   ' INT* optional, out
) As Short
End Function
' ConnectionHandle : void* in/out
' Attribute : INT
' Value : void* optional, out
' BufferLength : INT
' StringLengthPtr : INT* optional, out
Declare PtrSafe Function SQLGetConnectAttr Lib "odbc32" ( _
    ByVal ConnectionHandle As LongPtr, _
    ByVal Attribute As Long, _
    ByVal Value As LongPtr, _
    ByVal BufferLength As Long, _
    ByVal StringLengthPtr As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLGetConnectAttr = ctypes.windll.odbc32.SQLGetConnectAttr
SQLGetConnectAttr.restype = ctypes.c_short
SQLGetConnectAttr.argtypes = [
    ctypes.POINTER(None),  # ConnectionHandle : void* in/out
    ctypes.c_int,  # Attribute : INT
    ctypes.POINTER(None),  # Value : void* optional, out
    ctypes.c_int,  # BufferLength : INT
    ctypes.POINTER(ctypes.c_int),  # StringLengthPtr : INT* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLGetConnectAttr = Fiddle::Function.new(
  lib['SQLGetConnectAttr'],
  [
    Fiddle::TYPE_VOIDP,  # ConnectionHandle : void* in/out
    Fiddle::TYPE_INT,  # Attribute : INT
    Fiddle::TYPE_VOIDP,  # Value : void* optional, out
    Fiddle::TYPE_INT,  # BufferLength : INT
    Fiddle::TYPE_VOIDP,  # StringLengthPtr : INT* optional, out
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLGetConnectAttr(
        ConnectionHandle: *mut (),  // void* in/out
        Attribute: i32,  // INT
        Value: *mut (),  // void* optional, out
        BufferLength: i32,  // INT
        StringLengthPtr: *mut i32  // INT* optional, out
    ) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLGetConnectAttr(IntPtr ConnectionHandle, int Attribute, IntPtr Value, int BufferLength, IntPtr StringLengthPtr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetConnectAttr' -Namespace Win32 -PassThru
# $api::SQLGetConnectAttr(ConnectionHandle, Attribute, Value, BufferLength, StringLengthPtr)
#uselib "ODBC32.dll"
#func global SQLGetConnectAttr "SQLGetConnectAttr" sptr, sptr, sptr, sptr, sptr
; SQLGetConnectAttr ConnectionHandle, Attribute, Value, BufferLength, varptr(StringLengthPtr)   ; 戻り値は stat
; ConnectionHandle : void* in/out -> "sptr"
; Attribute : INT -> "sptr"
; Value : void* optional, out -> "sptr"
; BufferLength : INT -> "sptr"
; StringLengthPtr : INT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLGetConnectAttr "SQLGetConnectAttr" sptr, int, sptr, int, var
; res = SQLGetConnectAttr(ConnectionHandle, Attribute, Value, BufferLength, StringLengthPtr)
; ConnectionHandle : void* in/out -> "sptr"
; Attribute : INT -> "int"
; Value : void* optional, out -> "sptr"
; BufferLength : INT -> "int"
; StringLengthPtr : INT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLGetConnectAttr(void* ConnectionHandle, INT Attribute, void* Value, INT BufferLength, INT* StringLengthPtr)
#uselib "ODBC32.dll"
#cfunc global SQLGetConnectAttr "SQLGetConnectAttr" intptr, int, intptr, int, var
; res = SQLGetConnectAttr(ConnectionHandle, Attribute, Value, BufferLength, StringLengthPtr)
; ConnectionHandle : void* in/out -> "intptr"
; Attribute : INT -> "int"
; Value : void* optional, out -> "intptr"
; BufferLength : INT -> "int"
; StringLengthPtr : INT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLGetConnectAttr = odbc32.NewProc("SQLGetConnectAttr")
)

// ConnectionHandle (void* in/out), Attribute (INT), Value (void* optional, out), BufferLength (INT), StringLengthPtr (INT* optional, out)
r1, _, err := procSQLGetConnectAttr.Call(
	uintptr(ConnectionHandle),
	uintptr(Attribute),
	uintptr(Value),
	uintptr(BufferLength),
	uintptr(StringLengthPtr),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLGetConnectAttr(
  ConnectionHandle: Pointer;   // void* in/out
  Attribute: Integer;   // INT
  Value: Pointer;   // void* optional, out
  BufferLength: Integer;   // INT
  StringLengthPtr: Pointer   // INT* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLGetConnectAttr';
result := DllCall("ODBC32\SQLGetConnectAttr"
    , "Ptr", ConnectionHandle   ; void* in/out
    , "Int", Attribute   ; INT
    , "Ptr", Value   ; void* optional, out
    , "Int", BufferLength   ; INT
    , "Ptr", StringLengthPtr   ; INT* optional, out
    , "Short")   ; return: SHORT
●SQLGetConnectAttr(ConnectionHandle, Attribute, Value, BufferLength, StringLengthPtr) = DLL("ODBC32.dll", "int SQLGetConnectAttr(void*, int, void*, int, void*)")
# 呼び出し: SQLGetConnectAttr(ConnectionHandle, Attribute, Value, BufferLength, StringLengthPtr)
# ConnectionHandle : void* in/out -> "void*"
# Attribute : INT -> "int"
# Value : void* optional, out -> "void*"
# BufferLength : INT -> "int"
# StringLengthPtr : INT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。