ホーム › System.Search › SQLGetDescFieldA
SQLGetDescFieldA
関数記述子レコードの指定フィールド値を取得する(ANSI)。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetDescFieldA(
void* hdesc,
SHORT iRecord,
SHORT iField,
void* rgbValue, // optional
INT cbBufferLength,
INT* StringLength // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdesc | void* | inout | ODBCの記述子ハンドル。フィールド取得対象。 |
| iRecord | SHORT | in | 対象レコード番号。1始まりで指定する。 |
| iField | SHORT | in | 取得する記述子フィールド識別子。SQL_DESC_*定数。 |
| rgbValue | void* | outoptional | フィールド値を受け取るバッファ。出力用。 |
| cbBufferLength | INT | in | rgbValueバッファのバイト長。文字列フィールドで有効。 |
| StringLength | INT* | outoptional | 実際に返された値のバイト長を受け取るポインタ。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetDescFieldA(
void* hdesc,
SHORT iRecord,
SHORT iField,
void* rgbValue, // optional
INT cbBufferLength,
INT* StringLength // optional
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLGetDescFieldA(
IntPtr hdesc, // void* in/out
short iRecord, // SHORT
short iField, // SHORT
IntPtr rgbValue, // void* optional, out
int cbBufferLength, // INT
IntPtr StringLength // INT* optional, out
);<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLGetDescFieldA(
hdesc As IntPtr, ' void* in/out
iRecord As Short, ' SHORT
iField As Short, ' SHORT
rgbValue As IntPtr, ' void* optional, out
cbBufferLength As Integer, ' INT
StringLength As IntPtr ' INT* optional, out
) As Short
End Function' hdesc : void* in/out
' iRecord : SHORT
' iField : SHORT
' rgbValue : void* optional, out
' cbBufferLength : INT
' StringLength : INT* optional, out
Declare PtrSafe Function SQLGetDescFieldA Lib "odbc32" ( _
ByVal hdesc As LongPtr, _
ByVal iRecord As Integer, _
ByVal iField As Integer, _
ByVal rgbValue As LongPtr, _
ByVal cbBufferLength 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
SQLGetDescFieldA = ctypes.windll.odbc32.SQLGetDescFieldA
SQLGetDescFieldA.restype = ctypes.c_short
SQLGetDescFieldA.argtypes = [
ctypes.POINTER(None), # hdesc : void* in/out
ctypes.c_short, # iRecord : SHORT
ctypes.c_short, # iField : SHORT
ctypes.POINTER(None), # rgbValue : void* optional, out
ctypes.c_int, # cbBufferLength : INT
ctypes.POINTER(ctypes.c_int), # StringLength : INT* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLGetDescFieldA = Fiddle::Function.new(
lib['SQLGetDescFieldA'],
[
Fiddle::TYPE_VOIDP, # hdesc : void* in/out
Fiddle::TYPE_SHORT, # iRecord : SHORT
Fiddle::TYPE_SHORT, # iField : SHORT
Fiddle::TYPE_VOIDP, # rgbValue : void* optional, out
Fiddle::TYPE_INT, # cbBufferLength : INT
Fiddle::TYPE_VOIDP, # StringLength : INT* optional, out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLGetDescFieldA(
hdesc: *mut (), // void* in/out
iRecord: i16, // SHORT
iField: i16, // SHORT
rgbValue: *mut (), // void* optional, out
cbBufferLength: i32, // INT
StringLength: *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 SQLGetDescFieldA(IntPtr hdesc, short iRecord, short iField, IntPtr rgbValue, int cbBufferLength, IntPtr StringLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetDescFieldA' -Namespace Win32 -PassThru
# $api::SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength)#uselib "ODBC32.dll"
#func global SQLGetDescFieldA "SQLGetDescFieldA" sptr, sptr, sptr, sptr, sptr, sptr
; SQLGetDescFieldA hdesc, iRecord, iField, rgbValue, cbBufferLength, varptr(StringLength) ; 戻り値は stat
; hdesc : void* in/out -> "sptr"
; iRecord : SHORT -> "sptr"
; iField : SHORT -> "sptr"
; rgbValue : void* optional, out -> "sptr"
; cbBufferLength : INT -> "sptr"
; StringLength : INT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLGetDescFieldA "SQLGetDescFieldA" sptr, int, int, sptr, int, var ; res = SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength) ; hdesc : void* in/out -> "sptr" ; iRecord : SHORT -> "int" ; iField : SHORT -> "int" ; rgbValue : void* optional, out -> "sptr" ; cbBufferLength : INT -> "int" ; StringLength : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLGetDescFieldA "SQLGetDescFieldA" sptr, int, int, sptr, int, sptr ; res = SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, varptr(StringLength)) ; hdesc : void* in/out -> "sptr" ; iRecord : SHORT -> "int" ; iField : SHORT -> "int" ; rgbValue : void* optional, out -> "sptr" ; cbBufferLength : INT -> "int" ; StringLength : INT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLGetDescFieldA(void* hdesc, SHORT iRecord, SHORT iField, void* rgbValue, INT cbBufferLength, INT* StringLength) #uselib "ODBC32.dll" #cfunc global SQLGetDescFieldA "SQLGetDescFieldA" intptr, int, int, intptr, int, var ; res = SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength) ; hdesc : void* in/out -> "intptr" ; iRecord : SHORT -> "int" ; iField : SHORT -> "int" ; rgbValue : void* optional, out -> "intptr" ; cbBufferLength : INT -> "int" ; StringLength : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLGetDescFieldA(void* hdesc, SHORT iRecord, SHORT iField, void* rgbValue, INT cbBufferLength, INT* StringLength) #uselib "ODBC32.dll" #cfunc global SQLGetDescFieldA "SQLGetDescFieldA" intptr, int, int, intptr, int, intptr ; res = SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, varptr(StringLength)) ; hdesc : void* in/out -> "intptr" ; iRecord : SHORT -> "int" ; iField : SHORT -> "int" ; rgbValue : void* optional, out -> "intptr" ; cbBufferLength : INT -> "int" ; StringLength : INT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLGetDescFieldA = odbc32.NewProc("SQLGetDescFieldA")
)
// hdesc (void* in/out), iRecord (SHORT), iField (SHORT), rgbValue (void* optional, out), cbBufferLength (INT), StringLength (INT* optional, out)
r1, _, err := procSQLGetDescFieldA.Call(
uintptr(hdesc),
uintptr(iRecord),
uintptr(iField),
uintptr(rgbValue),
uintptr(cbBufferLength),
uintptr(StringLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLGetDescFieldA(
hdesc: Pointer; // void* in/out
iRecord: Smallint; // SHORT
iField: Smallint; // SHORT
rgbValue: Pointer; // void* optional, out
cbBufferLength: Integer; // INT
StringLength: Pointer // INT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetDescFieldA';result := DllCall("ODBC32\SQLGetDescFieldA"
, "Ptr", hdesc ; void* in/out
, "Short", iRecord ; SHORT
, "Short", iField ; SHORT
, "Ptr", rgbValue ; void* optional, out
, "Int", cbBufferLength ; INT
, "Ptr", StringLength ; INT* optional, out
, "Short") ; return: SHORT●SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength) = DLL("ODBC32.dll", "int SQLGetDescFieldA(void*, int, int, void*, int, void*)")
# 呼び出し: SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength)
# hdesc : void* in/out -> "void*"
# iRecord : SHORT -> "int"
# iField : SHORT -> "int"
# rgbValue : void* optional, out -> "void*"
# cbBufferLength : INT -> "int"
# StringLength : INT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLGetDescFieldA(
hdesc: ?*anyopaque, // void* in/out
iRecord: i16, // SHORT
iField: i16, // SHORT
rgbValue: ?*anyopaque, // void* optional, out
cbBufferLength: i32, // INT
StringLength: [*c]i32 // INT* optional, out
) callconv(std.os.windows.WINAPI) i16;proc SQLGetDescFieldA(
hdesc: pointer, # void* in/out
iRecord: int16, # SHORT
iField: int16, # SHORT
rgbValue: pointer, # void* optional, out
cbBufferLength: int32, # INT
StringLength: ptr int32 # INT* optional, out
): int16 {.importc: "SQLGetDescFieldA", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLGetDescFieldA(
void* hdesc, // void* in/out
short iRecord, // SHORT
short iField, // SHORT
void* rgbValue, // void* optional, out
int cbBufferLength, // INT
int* StringLength // INT* optional, out
);ccall((:SQLGetDescFieldA, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Int16, Int16, Ptr{Cvoid}, Int32, Ptr{Int32}),
hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength)
# hdesc : void* in/out -> Ptr{Cvoid}
# iRecord : SHORT -> Int16
# iField : SHORT -> Int16
# rgbValue : void* optional, out -> Ptr{Cvoid}
# cbBufferLength : INT -> Int32
# StringLength : INT* optional, out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLGetDescFieldA(
void* hdesc,
int16_t iRecord,
int16_t iField,
void* rgbValue,
int32_t cbBufferLength,
int32_t* StringLength);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength)
-- hdesc : void* in/out
-- iRecord : SHORT
-- iField : SHORT
-- rgbValue : void* optional, out
-- cbBufferLength : INT
-- StringLength : INT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLGetDescFieldA = lib.func('__stdcall', 'SQLGetDescFieldA', 'int16_t', ['void *', 'int16_t', 'int16_t', 'void *', 'int32_t', 'int32_t *']);
// SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength)
// hdesc : void* in/out -> 'void *'
// iRecord : SHORT -> 'int16_t'
// iField : SHORT -> 'int16_t'
// rgbValue : void* optional, out -> 'void *'
// cbBufferLength : INT -> 'int32_t'
// StringLength : INT* optional, out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLGetDescFieldA: { parameters: ["pointer", "i16", "i16", "pointer", "i32", "pointer"], result: "i16" },
});
// lib.symbols.SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength)
// hdesc : void* in/out -> "pointer"
// iRecord : SHORT -> "i16"
// iField : SHORT -> "i16"
// rgbValue : void* optional, out -> "pointer"
// cbBufferLength : INT -> "i32"
// StringLength : INT* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLGetDescFieldA(
void* hdesc,
int16_t iRecord,
int16_t iField,
void* rgbValue,
int32_t cbBufferLength,
int32_t* StringLength);
C, "ODBC32.dll");
// $ffi->SQLGetDescFieldA(hdesc, iRecord, iField, rgbValue, cbBufferLength, StringLength);
// hdesc : void* in/out
// iRecord : SHORT
// iField : SHORT
// rgbValue : void* optional, out
// cbBufferLength : INT
// StringLength : INT* 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, W32APIOptions.ASCII_OPTIONS);
short SQLGetDescFieldA(
Pointer hdesc, // void* in/out
short iRecord, // SHORT
short iField, // SHORT
Pointer rgbValue, // void* optional, out
int cbBufferLength, // INT
IntByReference StringLength // INT* optional, out
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLGetDescFieldA = SQLGetDescFieldA(
hdesc : Void*, # void* in/out
iRecord : Int16, # SHORT
iField : Int16, # SHORT
rgbValue : Void*, # void* optional, out
cbBufferLength : Int32, # INT
StringLength : Int32* # INT* 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 SQLGetDescFieldANative = Int16 Function(Pointer<Void>, Int16, Int16, Pointer<Void>, Int32, Pointer<Int32>);
typedef SQLGetDescFieldADart = int Function(Pointer<Void>, int, int, Pointer<Void>, int, Pointer<Int32>);
final SQLGetDescFieldA = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLGetDescFieldANative, SQLGetDescFieldADart>('SQLGetDescFieldA');
// hdesc : void* in/out -> Pointer<Void>
// iRecord : SHORT -> Int16
// iField : SHORT -> Int16
// rgbValue : void* optional, out -> Pointer<Void>
// cbBufferLength : INT -> Int32
// StringLength : INT* optional, out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLGetDescFieldA(
hdesc: Pointer; // void* in/out
iRecord: Smallint; // SHORT
iField: Smallint; // SHORT
rgbValue: Pointer; // void* optional, out
cbBufferLength: Integer; // INT
StringLength: Pointer // INT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetDescFieldA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLGetDescFieldA"
c_SQLGetDescFieldA :: Ptr () -> Int16 -> Int16 -> Ptr () -> Int32 -> Ptr Int32 -> IO Int16
-- hdesc : void* in/out -> Ptr ()
-- iRecord : SHORT -> Int16
-- iField : SHORT -> Int16
-- rgbValue : void* optional, out -> Ptr ()
-- cbBufferLength : INT -> Int32
-- StringLength : INT* optional, out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlgetdescfielda =
foreign "SQLGetDescFieldA"
((ptr void) @-> int16_t @-> int16_t @-> (ptr void) @-> int32_t @-> (ptr int32_t) @-> returning int16_t)
(* hdesc : void* in/out -> (ptr void) *)
(* iRecord : SHORT -> int16_t *)
(* iField : SHORT -> int16_t *)
(* rgbValue : void* optional, out -> (ptr void) *)
(* cbBufferLength : INT -> int32_t *)
(* StringLength : INT* optional, out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLGetDescFieldA" sqlget-desc-field-a :convention :stdcall) :int16
(hdesc :pointer) ; void* in/out
(i-record :int16) ; SHORT
(i-field :int16) ; SHORT
(rgb-value :pointer) ; void* optional, out
(cb-buffer-length :int32) ; INT
(string-length :pointer)) ; INT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLGetDescFieldA = Win32::API::More->new('ODBC32',
'short SQLGetDescFieldA(LPVOID hdesc, short iRecord, short iField, LPVOID rgbValue, int cbBufferLength, LPVOID StringLength)');
# my $ret = $SQLGetDescFieldA->Call($hdesc, $iRecord, $iField, $rgbValue, $cbBufferLength, $StringLength);
# hdesc : void* in/out -> LPVOID
# iRecord : SHORT -> short
# iField : SHORT -> short
# rgbValue : void* optional, out -> LPVOID
# cbBufferLength : INT -> int
# StringLength : INT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SQLGetDescFieldW (Unicode版) — 記述子レコードの指定フィールド値を取得する(Unicode)。