ホーム › System.Search › SQLGetConnectOptionW
SQLGetConnectOptionW
関数接続オプションの現在値を取得する(Unicode・非推奨)。
シグネチャ
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLGetConnectOptionW(
void* hdbc,
WORD fOption,
void* pvParam
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdbc | void* | inout | オプションを取得する接続ハンドル。 |
| fOption | WORD | in | 取得する接続オプションのID。非推奨API。 |
| pvParam | void* | inout | オプション値を受け取るバッファへのポインタ。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLGetConnectOptionW(
void* hdbc,
WORD fOption,
void* pvParam
);[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLGetConnectOptionW(
IntPtr hdbc, // void* in/out
ushort fOption, // WORD
IntPtr pvParam // void* in/out
);<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLGetConnectOptionW(
hdbc As IntPtr, ' void* in/out
fOption As UShort, ' WORD
pvParam As IntPtr ' void* in/out
) As Short
End Function' hdbc : void* in/out
' fOption : WORD
' pvParam : void* in/out
Declare PtrSafe Function SQLGetConnectOptionW Lib "odbc32" ( _
ByVal hdbc As LongPtr, _
ByVal fOption As Integer, _
ByVal pvParam As LongPtr) 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
SQLGetConnectOptionW = ctypes.windll.odbc32.SQLGetConnectOptionW
SQLGetConnectOptionW.restype = ctypes.c_short
SQLGetConnectOptionW.argtypes = [
ctypes.POINTER(None), # hdbc : void* in/out
ctypes.c_ushort, # fOption : WORD
ctypes.POINTER(None), # pvParam : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLGetConnectOptionW = Fiddle::Function.new(
lib['SQLGetConnectOptionW'],
[
Fiddle::TYPE_VOIDP, # hdbc : void* in/out
-Fiddle::TYPE_SHORT, # fOption : WORD
Fiddle::TYPE_VOIDP, # pvParam : void* in/out
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbc32")]
extern "system" {
fn SQLGetConnectOptionW(
hdbc: *mut (), // void* in/out
fOption: u16, // WORD
pvParam: *mut () // void* in/out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode)]
public static extern short SQLGetConnectOptionW(IntPtr hdbc, ushort fOption, IntPtr pvParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetConnectOptionW' -Namespace Win32 -PassThru
# $api::SQLGetConnectOptionW(hdbc, fOption, pvParam)#uselib "ODBC32.dll"
#func global SQLGetConnectOptionW "SQLGetConnectOptionW" wptr, wptr, wptr
; SQLGetConnectOptionW hdbc, fOption, pvParam ; 戻り値は stat
; hdbc : void* in/out -> "wptr"
; fOption : WORD -> "wptr"
; pvParam : void* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ODBC32.dll"
#cfunc global SQLGetConnectOptionW "SQLGetConnectOptionW" sptr, int, sptr
; res = SQLGetConnectOptionW(hdbc, fOption, pvParam)
; hdbc : void* in/out -> "sptr"
; fOption : WORD -> "int"
; pvParam : void* in/out -> "sptr"; SHORT SQLGetConnectOptionW(void* hdbc, WORD fOption, void* pvParam)
#uselib "ODBC32.dll"
#cfunc global SQLGetConnectOptionW "SQLGetConnectOptionW" intptr, int, intptr
; res = SQLGetConnectOptionW(hdbc, fOption, pvParam)
; hdbc : void* in/out -> "intptr"
; fOption : WORD -> "int"
; pvParam : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLGetConnectOptionW = odbc32.NewProc("SQLGetConnectOptionW")
)
// hdbc (void* in/out), fOption (WORD), pvParam (void* in/out)
r1, _, err := procSQLGetConnectOptionW.Call(
uintptr(hdbc),
uintptr(fOption),
uintptr(pvParam),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLGetConnectOptionW(
hdbc: Pointer; // void* in/out
fOption: Word; // WORD
pvParam: Pointer // void* in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetConnectOptionW';result := DllCall("ODBC32\SQLGetConnectOptionW"
, "Ptr", hdbc ; void* in/out
, "UShort", fOption ; WORD
, "Ptr", pvParam ; void* in/out
, "Short") ; return: SHORT●SQLGetConnectOptionW(hdbc, fOption, pvParam) = DLL("ODBC32.dll", "int SQLGetConnectOptionW(void*, int, void*)")
# 呼び出し: SQLGetConnectOptionW(hdbc, fOption, pvParam)
# hdbc : void* in/out -> "void*"
# fOption : WORD -> "int"
# pvParam : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "odbc32" fn SQLGetConnectOptionW(
hdbc: ?*anyopaque, // void* in/out
fOption: u16, // WORD
pvParam: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SQLGetConnectOptionW(
hdbc: pointer, # void* in/out
fOption: uint16, # WORD
pvParam: pointer # void* in/out
): int16 {.importc: "SQLGetConnectOptionW", stdcall, dynlib: "ODBC32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "odbc32");
extern(Windows)
short SQLGetConnectOptionW(
void* hdbc, // void* in/out
ushort fOption, // WORD
void* pvParam // void* in/out
);ccall((:SQLGetConnectOptionW, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, UInt16, Ptr{Cvoid}),
hdbc, fOption, pvParam)
# hdbc : void* in/out -> Ptr{Cvoid}
# fOption : WORD -> UInt16
# pvParam : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLGetConnectOptionW(
void* hdbc,
uint16_t fOption,
void* pvParam);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLGetConnectOptionW(hdbc, fOption, pvParam)
-- hdbc : void* in/out
-- fOption : WORD
-- pvParam : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLGetConnectOptionW = lib.func('__stdcall', 'SQLGetConnectOptionW', 'int16_t', ['void *', 'uint16_t', 'void *']);
// SQLGetConnectOptionW(hdbc, fOption, pvParam)
// hdbc : void* in/out -> 'void *'
// fOption : WORD -> 'uint16_t'
// pvParam : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLGetConnectOptionW: { parameters: ["pointer", "u16", "pointer"], result: "i16" },
});
// lib.symbols.SQLGetConnectOptionW(hdbc, fOption, pvParam)
// hdbc : void* in/out -> "pointer"
// fOption : WORD -> "u16"
// pvParam : void* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLGetConnectOptionW(
void* hdbc,
uint16_t fOption,
void* pvParam);
C, "ODBC32.dll");
// $ffi->SQLGetConnectOptionW(hdbc, fOption, pvParam);
// hdbc : void* in/out
// fOption : WORD
// pvParam : void* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Odbc32 extends StdCallLibrary {
Odbc32 INSTANCE = Native.load("odbc32", Odbc32.class, W32APIOptions.UNICODE_OPTIONS);
short SQLGetConnectOptionW(
Pointer hdbc, // void* in/out
short fOption, // WORD
Pointer pvParam // void* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("odbc32")]
lib LibODBC32
fun SQLGetConnectOptionW = SQLGetConnectOptionW(
hdbc : Void*, # void* in/out
fOption : UInt16, # WORD
pvParam : Void* # void* in/out
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLGetConnectOptionWNative = Int16 Function(Pointer<Void>, Uint16, Pointer<Void>);
typedef SQLGetConnectOptionWDart = int Function(Pointer<Void>, int, Pointer<Void>);
final SQLGetConnectOptionW = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLGetConnectOptionWNative, SQLGetConnectOptionWDart>('SQLGetConnectOptionW');
// hdbc : void* in/out -> Pointer<Void>
// fOption : WORD -> Uint16
// pvParam : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLGetConnectOptionW(
hdbc: Pointer; // void* in/out
fOption: Word; // WORD
pvParam: Pointer // void* in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetConnectOptionW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLGetConnectOptionW"
c_SQLGetConnectOptionW :: Ptr () -> Word16 -> Ptr () -> IO Int16
-- hdbc : void* in/out -> Ptr ()
-- fOption : WORD -> Word16
-- pvParam : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlgetconnectoptionw =
foreign "SQLGetConnectOptionW"
((ptr void) @-> uint16_t @-> (ptr void) @-> returning int16_t)
(* hdbc : void* in/out -> (ptr void) *)
(* fOption : WORD -> uint16_t *)
(* pvParam : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLGetConnectOptionW" sqlget-connect-option-w :convention :stdcall) :int16
(hdbc :pointer) ; void* in/out
(f-option :uint16) ; WORD
(pv-param :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLGetConnectOptionW = Win32::API::More->new('ODBC32',
'short SQLGetConnectOptionW(LPVOID hdbc, WORD fOption, LPVOID pvParam)');
# my $ret = $SQLGetConnectOptionW->Call($hdbc, $fOption, $pvParam);
# hdbc : void* in/out -> LPVOID
# fOption : WORD -> WORD
# pvParam : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SQLGetConnectOptionA (ANSI版) — ODBC接続オプションの現在値を取得する。