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