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

SQLGetConnectAttrA

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

シグネチャ

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

SHORT SQLGetConnectAttrA(
    void* hdbc,
    INT fAttribute,
    void* rgbValue,   // optional
    INT cbValueMax,
    INT* pcbValue   // optional
);

パラメーター

名前方向
hdbcvoid*inout
fAttributeINTin
rgbValuevoid*outoptional
cbValueMaxINTin
pcbValueINT*outoptional

戻り値の型: SHORT

各言語での呼び出し定義

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

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

SQLGetConnectAttrA = ctypes.windll.odbc32.SQLGetConnectAttrA
SQLGetConnectAttrA.restype = ctypes.c_short
SQLGetConnectAttrA.argtypes = [
    ctypes.POINTER(None),  # hdbc : void* in/out
    ctypes.c_int,  # fAttribute : INT
    ctypes.POINTER(None),  # rgbValue : void* optional, out
    ctypes.c_int,  # cbValueMax : INT
    ctypes.POINTER(ctypes.c_int),  # pcbValue : INT* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLGetConnectAttrA = Fiddle::Function.new(
  lib['SQLGetConnectAttrA'],
  [
    Fiddle::TYPE_VOIDP,  # hdbc : void* in/out
    Fiddle::TYPE_INT,  # fAttribute : INT
    Fiddle::TYPE_VOIDP,  # rgbValue : void* optional, out
    Fiddle::TYPE_INT,  # cbValueMax : INT
    Fiddle::TYPE_VOIDP,  # pcbValue : INT* optional, out
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLGetConnectAttrA(
        hdbc: *mut (),  // void* in/out
        fAttribute: i32,  // INT
        rgbValue: *mut (),  // void* optional, out
        cbValueMax: i32,  // INT
        pcbValue: *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 SQLGetConnectAttrA(IntPtr hdbc, int fAttribute, IntPtr rgbValue, int cbValueMax, IntPtr pcbValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetConnectAttrA' -Namespace Win32 -PassThru
# $api::SQLGetConnectAttrA(hdbc, fAttribute, rgbValue, cbValueMax, pcbValue)
#uselib "ODBC32.dll"
#func global SQLGetConnectAttrA "SQLGetConnectAttrA" sptr, sptr, sptr, sptr, sptr
; SQLGetConnectAttrA hdbc, fAttribute, rgbValue, cbValueMax, varptr(pcbValue)   ; 戻り値は stat
; hdbc : void* in/out -> "sptr"
; fAttribute : INT -> "sptr"
; rgbValue : void* optional, out -> "sptr"
; cbValueMax : INT -> "sptr"
; pcbValue : INT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLGetConnectAttrA "SQLGetConnectAttrA" sptr, int, sptr, int, var
; res = SQLGetConnectAttrA(hdbc, fAttribute, rgbValue, cbValueMax, pcbValue)
; hdbc : void* in/out -> "sptr"
; fAttribute : INT -> "int"
; rgbValue : void* optional, out -> "sptr"
; cbValueMax : INT -> "int"
; pcbValue : INT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLGetConnectAttrA(void* hdbc, INT fAttribute, void* rgbValue, INT cbValueMax, INT* pcbValue)
#uselib "ODBC32.dll"
#cfunc global SQLGetConnectAttrA "SQLGetConnectAttrA" intptr, int, intptr, int, var
; res = SQLGetConnectAttrA(hdbc, fAttribute, rgbValue, cbValueMax, pcbValue)
; hdbc : void* in/out -> "intptr"
; fAttribute : INT -> "int"
; rgbValue : void* optional, out -> "intptr"
; cbValueMax : INT -> "int"
; pcbValue : INT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLGetConnectAttrA = odbc32.NewProc("SQLGetConnectAttrA")
)

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