ホーム › System.Search › SQLGetFunctions
SQLGetFunctions
関数ドライバが特定のODBC関数を対応するか問い合わせる。
シグネチャ
// ODBC32.dll
#include <windows.h>
SHORT SQLGetFunctions(
void* ConnectionHandle,
WORD FunctionId,
WORD* Supported // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ConnectionHandle | void* | inout | 対象の接続ハンドル。ドライバの機能を問い合わせる。 |
| FunctionId | WORD | in | 問い合わせる関数のID。SQL_API_*定数またはSQL_API_ODBC3_ALL_FUNCTIONS。 |
| Supported | WORD* | outoptional | 当該関数のサポート有無を受け取るポインタ。TRUE/FALSEまたはビット配列。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll
#include <windows.h>
SHORT SQLGetFunctions(
void* ConnectionHandle,
WORD FunctionId,
WORD* Supported // optional
);[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLGetFunctions(
IntPtr ConnectionHandle, // void* in/out
ushort FunctionId, // WORD
IntPtr Supported // WORD* optional, out
);<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLGetFunctions(
ConnectionHandle As IntPtr, ' void* in/out
FunctionId As UShort, ' WORD
Supported As IntPtr ' WORD* optional, out
) As Short
End Function' ConnectionHandle : void* in/out
' FunctionId : WORD
' Supported : WORD* optional, out
Declare PtrSafe Function SQLGetFunctions Lib "odbc32" ( _
ByVal ConnectionHandle As LongPtr, _
ByVal FunctionId As Integer, _
ByVal Supported As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLGetFunctions = ctypes.windll.odbc32.SQLGetFunctions
SQLGetFunctions.restype = ctypes.c_short
SQLGetFunctions.argtypes = [
ctypes.POINTER(None), # ConnectionHandle : void* in/out
ctypes.c_ushort, # FunctionId : WORD
ctypes.POINTER(ctypes.c_ushort), # Supported : WORD* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLGetFunctions = Fiddle::Function.new(
lib['SQLGetFunctions'],
[
Fiddle::TYPE_VOIDP, # ConnectionHandle : void* in/out
-Fiddle::TYPE_SHORT, # FunctionId : WORD
Fiddle::TYPE_VOIDP, # Supported : WORD* optional, out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLGetFunctions(
ConnectionHandle: *mut (), // void* in/out
FunctionId: u16, // WORD
Supported: *mut u16 // WORD* optional, out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLGetFunctions(IntPtr ConnectionHandle, ushort FunctionId, IntPtr Supported);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetFunctions' -Namespace Win32 -PassThru
# $api::SQLGetFunctions(ConnectionHandle, FunctionId, Supported)#uselib "ODBC32.dll"
#func global SQLGetFunctions "SQLGetFunctions" sptr, sptr, sptr
; SQLGetFunctions ConnectionHandle, FunctionId, varptr(Supported) ; 戻り値は stat
; ConnectionHandle : void* in/out -> "sptr"
; FunctionId : WORD -> "sptr"
; Supported : WORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLGetFunctions "SQLGetFunctions" sptr, int, var ; res = SQLGetFunctions(ConnectionHandle, FunctionId, Supported) ; ConnectionHandle : void* in/out -> "sptr" ; FunctionId : WORD -> "int" ; Supported : WORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLGetFunctions "SQLGetFunctions" sptr, int, sptr ; res = SQLGetFunctions(ConnectionHandle, FunctionId, varptr(Supported)) ; ConnectionHandle : void* in/out -> "sptr" ; FunctionId : WORD -> "int" ; Supported : WORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLGetFunctions(void* ConnectionHandle, WORD FunctionId, WORD* Supported) #uselib "ODBC32.dll" #cfunc global SQLGetFunctions "SQLGetFunctions" intptr, int, var ; res = SQLGetFunctions(ConnectionHandle, FunctionId, Supported) ; ConnectionHandle : void* in/out -> "intptr" ; FunctionId : WORD -> "int" ; Supported : WORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLGetFunctions(void* ConnectionHandle, WORD FunctionId, WORD* Supported) #uselib "ODBC32.dll" #cfunc global SQLGetFunctions "SQLGetFunctions" intptr, int, intptr ; res = SQLGetFunctions(ConnectionHandle, FunctionId, varptr(Supported)) ; ConnectionHandle : void* in/out -> "intptr" ; FunctionId : WORD -> "int" ; Supported : WORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLGetFunctions = odbc32.NewProc("SQLGetFunctions")
)
// ConnectionHandle (void* in/out), FunctionId (WORD), Supported (WORD* optional, out)
r1, _, err := procSQLGetFunctions.Call(
uintptr(ConnectionHandle),
uintptr(FunctionId),
uintptr(Supported),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLGetFunctions(
ConnectionHandle: Pointer; // void* in/out
FunctionId: Word; // WORD
Supported: Pointer // WORD* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetFunctions';result := DllCall("ODBC32\SQLGetFunctions"
, "Ptr", ConnectionHandle ; void* in/out
, "UShort", FunctionId ; WORD
, "Ptr", Supported ; WORD* optional, out
, "Short") ; return: SHORT●SQLGetFunctions(ConnectionHandle, FunctionId, Supported) = DLL("ODBC32.dll", "int SQLGetFunctions(void*, int, void*)")
# 呼び出し: SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
# ConnectionHandle : void* in/out -> "void*"
# FunctionId : WORD -> "int"
# Supported : WORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLGetFunctions(
ConnectionHandle: ?*anyopaque, // void* in/out
FunctionId: u16, // WORD
Supported: [*c]u16 // WORD* optional, out
) callconv(std.os.windows.WINAPI) i16;proc SQLGetFunctions(
ConnectionHandle: pointer, # void* in/out
FunctionId: uint16, # WORD
Supported: ptr uint16 # WORD* optional, out
): int16 {.importc: "SQLGetFunctions", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLGetFunctions(
void* ConnectionHandle, // void* in/out
ushort FunctionId, // WORD
ushort* Supported // WORD* optional, out
);ccall((:SQLGetFunctions, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, UInt16, Ptr{UInt16}),
ConnectionHandle, FunctionId, Supported)
# ConnectionHandle : void* in/out -> Ptr{Cvoid}
# FunctionId : WORD -> UInt16
# Supported : WORD* optional, out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLGetFunctions(
void* ConnectionHandle,
uint16_t FunctionId,
uint16_t* Supported);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
-- ConnectionHandle : void* in/out
-- FunctionId : WORD
-- Supported : WORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLGetFunctions = lib.func('__stdcall', 'SQLGetFunctions', 'int16_t', ['void *', 'uint16_t', 'uint16_t *']);
// SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
// ConnectionHandle : void* in/out -> 'void *'
// FunctionId : WORD -> 'uint16_t'
// Supported : WORD* optional, out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLGetFunctions: { parameters: ["pointer", "u16", "pointer"], result: "i16" },
});
// lib.symbols.SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
// ConnectionHandle : void* in/out -> "pointer"
// FunctionId : WORD -> "u16"
// Supported : WORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLGetFunctions(
void* ConnectionHandle,
uint16_t FunctionId,
uint16_t* Supported);
C, "ODBC32.dll");
// $ffi->SQLGetFunctions(ConnectionHandle, FunctionId, Supported);
// ConnectionHandle : void* in/out
// FunctionId : WORD
// Supported : WORD* optional, 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);
short SQLGetFunctions(
Pointer ConnectionHandle, // void* in/out
short FunctionId, // WORD
ShortByReference Supported // WORD* optional, out
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLGetFunctions = SQLGetFunctions(
ConnectionHandle : Void*, # void* in/out
FunctionId : UInt16, # WORD
Supported : UInt16* # WORD* optional, out
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLGetFunctionsNative = Int16 Function(Pointer<Void>, Uint16, Pointer<Uint16>);
typedef SQLGetFunctionsDart = int Function(Pointer<Void>, int, Pointer<Uint16>);
final SQLGetFunctions = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLGetFunctionsNative, SQLGetFunctionsDart>('SQLGetFunctions');
// ConnectionHandle : void* in/out -> Pointer<Void>
// FunctionId : WORD -> Uint16
// Supported : WORD* optional, out -> Pointer<Uint16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLGetFunctions(
ConnectionHandle: Pointer; // void* in/out
FunctionId: Word; // WORD
Supported: Pointer // WORD* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetFunctions';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLGetFunctions"
c_SQLGetFunctions :: Ptr () -> Word16 -> Ptr Word16 -> IO Int16
-- ConnectionHandle : void* in/out -> Ptr ()
-- FunctionId : WORD -> Word16
-- Supported : WORD* optional, out -> Ptr Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlgetfunctions =
foreign "SQLGetFunctions"
((ptr void) @-> uint16_t @-> (ptr uint16_t) @-> returning int16_t)
(* ConnectionHandle : void* in/out -> (ptr void) *)
(* FunctionId : WORD -> uint16_t *)
(* Supported : WORD* optional, out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLGetFunctions" sqlget-functions :convention :stdcall) :int16
(connection-handle :pointer) ; void* in/out
(function-id :uint16) ; WORD
(supported :pointer)) ; WORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLGetFunctions = Win32::API::More->new('ODBC32',
'short SQLGetFunctions(LPVOID ConnectionHandle, WORD FunctionId, LPVOID Supported)');
# my $ret = $SQLGetFunctions->Call($ConnectionHandle, $FunctionId, $Supported);
# ConnectionHandle : void* in/out -> LPVOID
# FunctionId : WORD -> WORD
# Supported : WORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。