ホーム › System.Search › SQLSetConnectAttrW
SQLSetConnectAttrW
関数接続属性に値を設定する(Unicode)。
シグネチャ
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLSetConnectAttrW(
void* hdbc,
INT fAttribute,
void* rgbValue, // optional
INT cbValue
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdbc | void* | inout |
| fAttribute | INT | in |
| rgbValue | void* | inoptional |
| cbValue | INT | in |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLSetConnectAttrW(
void* hdbc,
INT fAttribute,
void* rgbValue, // optional
INT cbValue
);[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLSetConnectAttrW(
IntPtr hdbc, // void* in/out
int fAttribute, // INT
IntPtr rgbValue, // void* optional
int cbValue // INT
);<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLSetConnectAttrW(
hdbc As IntPtr, ' void* in/out
fAttribute As Integer, ' INT
rgbValue As IntPtr, ' void* optional
cbValue As Integer ' INT
) As Short
End Function' hdbc : void* in/out
' fAttribute : INT
' rgbValue : void* optional
' cbValue : INT
Declare PtrSafe Function SQLSetConnectAttrW Lib "odbc32" ( _
ByVal hdbc As LongPtr, _
ByVal fAttribute As Long, _
ByVal rgbValue As LongPtr, _
ByVal cbValue As Long) 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
SQLSetConnectAttrW = ctypes.windll.odbc32.SQLSetConnectAttrW
SQLSetConnectAttrW.restype = ctypes.c_short
SQLSetConnectAttrW.argtypes = [
ctypes.POINTER(None), # hdbc : void* in/out
ctypes.c_int, # fAttribute : INT
ctypes.POINTER(None), # rgbValue : void* optional
ctypes.c_int, # cbValue : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLSetConnectAttrW = Fiddle::Function.new(
lib['SQLSetConnectAttrW'],
[
Fiddle::TYPE_VOIDP, # hdbc : void* in/out
Fiddle::TYPE_INT, # fAttribute : INT
Fiddle::TYPE_VOIDP, # rgbValue : void* optional
Fiddle::TYPE_INT, # cbValue : INT
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbc32")]
extern "system" {
fn SQLSetConnectAttrW(
hdbc: *mut (), // void* in/out
fAttribute: i32, // INT
rgbValue: *mut (), // void* optional
cbValue: i32 // INT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode)]
public static extern short SQLSetConnectAttrW(IntPtr hdbc, int fAttribute, IntPtr rgbValue, int cbValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLSetConnectAttrW' -Namespace Win32 -PassThru
# $api::SQLSetConnectAttrW(hdbc, fAttribute, rgbValue, cbValue)#uselib "ODBC32.dll"
#func global SQLSetConnectAttrW "SQLSetConnectAttrW" wptr, wptr, wptr, wptr
; SQLSetConnectAttrW hdbc, fAttribute, rgbValue, cbValue ; 戻り値は stat
; hdbc : void* in/out -> "wptr"
; fAttribute : INT -> "wptr"
; rgbValue : void* optional -> "wptr"
; cbValue : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ODBC32.dll"
#cfunc global SQLSetConnectAttrW "SQLSetConnectAttrW" sptr, int, sptr, int
; res = SQLSetConnectAttrW(hdbc, fAttribute, rgbValue, cbValue)
; hdbc : void* in/out -> "sptr"
; fAttribute : INT -> "int"
; rgbValue : void* optional -> "sptr"
; cbValue : INT -> "int"; SHORT SQLSetConnectAttrW(void* hdbc, INT fAttribute, void* rgbValue, INT cbValue)
#uselib "ODBC32.dll"
#cfunc global SQLSetConnectAttrW "SQLSetConnectAttrW" intptr, int, intptr, int
; res = SQLSetConnectAttrW(hdbc, fAttribute, rgbValue, cbValue)
; hdbc : void* in/out -> "intptr"
; fAttribute : INT -> "int"
; rgbValue : void* optional -> "intptr"
; cbValue : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLSetConnectAttrW = odbc32.NewProc("SQLSetConnectAttrW")
)
// hdbc (void* in/out), fAttribute (INT), rgbValue (void* optional), cbValue (INT)
r1, _, err := procSQLSetConnectAttrW.Call(
uintptr(hdbc),
uintptr(fAttribute),
uintptr(rgbValue),
uintptr(cbValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLSetConnectAttrW(
hdbc: Pointer; // void* in/out
fAttribute: Integer; // INT
rgbValue: Pointer; // void* optional
cbValue: Integer // INT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetConnectAttrW';result := DllCall("ODBC32\SQLSetConnectAttrW"
, "Ptr", hdbc ; void* in/out
, "Int", fAttribute ; INT
, "Ptr", rgbValue ; void* optional
, "Int", cbValue ; INT
, "Short") ; return: SHORT●SQLSetConnectAttrW(hdbc, fAttribute, rgbValue, cbValue) = DLL("ODBC32.dll", "int SQLSetConnectAttrW(void*, int, void*, int)")
# 呼び出し: SQLSetConnectAttrW(hdbc, fAttribute, rgbValue, cbValue)
# hdbc : void* in/out -> "void*"
# fAttribute : INT -> "int"
# rgbValue : void* optional -> "void*"
# cbValue : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。