Win32 API 日本語リファレンス
ホームSystem.Search › SQLTablesA

SQLTablesA

関数
データソース内のテーブルの一覧情報を取得する。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLTablesA(
    void* hstmt,
    BYTE* szCatalogName,   // optional
    SHORT cbCatalogName,
    BYTE* szSchemaName,   // optional
    SHORT cbSchemaName,
    BYTE* szTableName,   // optional
    SHORT cbTableName,
    BYTE* szTableType,   // optional
    SHORT cbTableType
);

パラメーター

名前方向説明
hstmtvoid*inoutODBCのステートメントハンドル。テーブル一覧の結果セットを返す。
szCatalogNameBYTE*inoptional検索対象のカタログ名。NULLやパターンで絞り込む。
cbCatalogNameSHORTinszCatalogNameのバイト数。SQL_NTSでNUL終端とみなす。
szSchemaNameBYTE*inoptional検索対象のスキーマ名。NULLやパターンで絞り込む。
cbSchemaNameSHORTinszSchemaNameのバイト数。SQL_NTSでNUL終端とみなす。
szTableNameBYTE*inoptional検索対象のテーブル名。NULLやパターンで絞り込む。
cbTableNameSHORTinszTableNameのバイト数。SQL_NTSでNUL終端とみなす。
szTableTypeBYTE*inoptional対象テーブル種別のリスト(TABLE,VIEW等のカンマ区切り)。
cbTableTypeSHORTinszTableTypeのバイト数。SQL_NTSでNUL終端とみなす。

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLTablesA(
    void* hstmt,
    BYTE* szCatalogName,   // optional
    SHORT cbCatalogName,
    BYTE* szSchemaName,   // optional
    SHORT cbSchemaName,
    BYTE* szTableName,   // optional
    SHORT cbTableName,
    BYTE* szTableType,   // optional
    SHORT cbTableType
);
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLTablesA(
    IntPtr hstmt,   // void* in/out
    IntPtr szCatalogName,   // BYTE* optional
    short cbCatalogName,   // SHORT
    IntPtr szSchemaName,   // BYTE* optional
    short cbSchemaName,   // SHORT
    IntPtr szTableName,   // BYTE* optional
    short cbTableName,   // SHORT
    IntPtr szTableType,   // BYTE* optional
    short cbTableType   // SHORT
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLTablesA(
    hstmt As IntPtr,   ' void* in/out
    szCatalogName As IntPtr,   ' BYTE* optional
    cbCatalogName As Short,   ' SHORT
    szSchemaName As IntPtr,   ' BYTE* optional
    cbSchemaName As Short,   ' SHORT
    szTableName As IntPtr,   ' BYTE* optional
    cbTableName As Short,   ' SHORT
    szTableType As IntPtr,   ' BYTE* optional
    cbTableType As Short   ' SHORT
) As Short
End Function
' hstmt : void* in/out
' szCatalogName : BYTE* optional
' cbCatalogName : SHORT
' szSchemaName : BYTE* optional
' cbSchemaName : SHORT
' szTableName : BYTE* optional
' cbTableName : SHORT
' szTableType : BYTE* optional
' cbTableType : SHORT
Declare PtrSafe Function SQLTablesA Lib "odbc32" ( _
    ByVal hstmt As LongPtr, _
    ByVal szCatalogName As LongPtr, _
    ByVal cbCatalogName As Integer, _
    ByVal szSchemaName As LongPtr, _
    ByVal cbSchemaName As Integer, _
    ByVal szTableName As LongPtr, _
    ByVal cbTableName As Integer, _
    ByVal szTableType As LongPtr, _
    ByVal cbTableType As Integer) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLTablesA = ctypes.windll.odbc32.SQLTablesA
SQLTablesA.restype = ctypes.c_short
SQLTablesA.argtypes = [
    ctypes.POINTER(None),  # hstmt : void* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # szCatalogName : BYTE* optional
    ctypes.c_short,  # cbCatalogName : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # szSchemaName : BYTE* optional
    ctypes.c_short,  # cbSchemaName : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # szTableName : BYTE* optional
    ctypes.c_short,  # cbTableName : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # szTableType : BYTE* optional
    ctypes.c_short,  # cbTableType : SHORT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLTablesA = Fiddle::Function.new(
  lib['SQLTablesA'],
  [
    Fiddle::TYPE_VOIDP,  # hstmt : void* in/out
    Fiddle::TYPE_VOIDP,  # szCatalogName : BYTE* optional
    Fiddle::TYPE_SHORT,  # cbCatalogName : SHORT
    Fiddle::TYPE_VOIDP,  # szSchemaName : BYTE* optional
    Fiddle::TYPE_SHORT,  # cbSchemaName : SHORT
    Fiddle::TYPE_VOIDP,  # szTableName : BYTE* optional
    Fiddle::TYPE_SHORT,  # cbTableName : SHORT
    Fiddle::TYPE_VOIDP,  # szTableType : BYTE* optional
    Fiddle::TYPE_SHORT,  # cbTableType : SHORT
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLTablesA(
        hstmt: *mut (),  // void* in/out
        szCatalogName: *mut u8,  // BYTE* optional
        cbCatalogName: i16,  // SHORT
        szSchemaName: *mut u8,  // BYTE* optional
        cbSchemaName: i16,  // SHORT
        szTableName: *mut u8,  // BYTE* optional
        cbTableName: i16,  // SHORT
        szTableType: *mut u8,  // BYTE* optional
        cbTableType: i16  // SHORT
    ) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLTablesA(IntPtr hstmt, IntPtr szCatalogName, short cbCatalogName, IntPtr szSchemaName, short cbSchemaName, IntPtr szTableName, short cbTableName, IntPtr szTableType, short cbTableType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLTablesA' -Namespace Win32 -PassThru
# $api::SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
#uselib "ODBC32.dll"
#func global SQLTablesA "SQLTablesA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLTablesA hstmt, varptr(szCatalogName), cbCatalogName, varptr(szSchemaName), cbSchemaName, varptr(szTableName), cbTableName, varptr(szTableType), cbTableType   ; 戻り値は stat
; hstmt : void* in/out -> "sptr"
; szCatalogName : BYTE* optional -> "sptr"
; cbCatalogName : SHORT -> "sptr"
; szSchemaName : BYTE* optional -> "sptr"
; cbSchemaName : SHORT -> "sptr"
; szTableName : BYTE* optional -> "sptr"
; cbTableName : SHORT -> "sptr"
; szTableType : BYTE* optional -> "sptr"
; cbTableType : SHORT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLTablesA "SQLTablesA" sptr, var, int, var, int, var, int, var, int
; res = SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
; hstmt : void* in/out -> "sptr"
; szCatalogName : BYTE* optional -> "var"
; cbCatalogName : SHORT -> "int"
; szSchemaName : BYTE* optional -> "var"
; cbSchemaName : SHORT -> "int"
; szTableName : BYTE* optional -> "var"
; cbTableName : SHORT -> "int"
; szTableType : BYTE* optional -> "var"
; cbTableType : SHORT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLTablesA(void* hstmt, BYTE* szCatalogName, SHORT cbCatalogName, BYTE* szSchemaName, SHORT cbSchemaName, BYTE* szTableName, SHORT cbTableName, BYTE* szTableType, SHORT cbTableType)
#uselib "ODBC32.dll"
#cfunc global SQLTablesA "SQLTablesA" intptr, var, int, var, int, var, int, var, int
; res = SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
; hstmt : void* in/out -> "intptr"
; szCatalogName : BYTE* optional -> "var"
; cbCatalogName : SHORT -> "int"
; szSchemaName : BYTE* optional -> "var"
; cbSchemaName : SHORT -> "int"
; szTableName : BYTE* optional -> "var"
; cbTableName : SHORT -> "int"
; szTableType : BYTE* optional -> "var"
; cbTableType : SHORT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLTablesA = odbc32.NewProc("SQLTablesA")
)

// hstmt (void* in/out), szCatalogName (BYTE* optional), cbCatalogName (SHORT), szSchemaName (BYTE* optional), cbSchemaName (SHORT), szTableName (BYTE* optional), cbTableName (SHORT), szTableType (BYTE* optional), cbTableType (SHORT)
r1, _, err := procSQLTablesA.Call(
	uintptr(hstmt),
	uintptr(szCatalogName),
	uintptr(cbCatalogName),
	uintptr(szSchemaName),
	uintptr(cbSchemaName),
	uintptr(szTableName),
	uintptr(cbTableName),
	uintptr(szTableType),
	uintptr(cbTableType),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLTablesA(
  hstmt: Pointer;   // void* in/out
  szCatalogName: Pointer;   // BYTE* optional
  cbCatalogName: Smallint;   // SHORT
  szSchemaName: Pointer;   // BYTE* optional
  cbSchemaName: Smallint;   // SHORT
  szTableName: Pointer;   // BYTE* optional
  cbTableName: Smallint;   // SHORT
  szTableType: Pointer;   // BYTE* optional
  cbTableType: Smallint   // SHORT
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLTablesA';
result := DllCall("ODBC32\SQLTablesA"
    , "Ptr", hstmt   ; void* in/out
    , "Ptr", szCatalogName   ; BYTE* optional
    , "Short", cbCatalogName   ; SHORT
    , "Ptr", szSchemaName   ; BYTE* optional
    , "Short", cbSchemaName   ; SHORT
    , "Ptr", szTableName   ; BYTE* optional
    , "Short", cbTableName   ; SHORT
    , "Ptr", szTableType   ; BYTE* optional
    , "Short", cbTableType   ; SHORT
    , "Short")   ; return: SHORT
●SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType) = DLL("ODBC32.dll", "int SQLTablesA(void*, void*, int, void*, int, void*, int, void*, int)")
# 呼び出し: SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
# hstmt : void* in/out -> "void*"
# szCatalogName : BYTE* optional -> "void*"
# cbCatalogName : SHORT -> "int"
# szSchemaName : BYTE* optional -> "void*"
# cbSchemaName : SHORT -> "int"
# szTableName : BYTE* optional -> "void*"
# cbTableName : SHORT -> "int"
# szTableType : BYTE* optional -> "void*"
# cbTableType : SHORT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "odbc32" fn SQLTablesA(
    hstmt: ?*anyopaque, // void* in/out
    szCatalogName: [*c]u8, // BYTE* optional
    cbCatalogName: i16, // SHORT
    szSchemaName: [*c]u8, // BYTE* optional
    cbSchemaName: i16, // SHORT
    szTableName: [*c]u8, // BYTE* optional
    cbTableName: i16, // SHORT
    szTableType: [*c]u8, // BYTE* optional
    cbTableType: i16 // SHORT
) callconv(std.os.windows.WINAPI) i16;
proc SQLTablesA(
    hstmt: pointer,  # void* in/out
    szCatalogName: ptr uint8,  # BYTE* optional
    cbCatalogName: int16,  # SHORT
    szSchemaName: ptr uint8,  # BYTE* optional
    cbSchemaName: int16,  # SHORT
    szTableName: ptr uint8,  # BYTE* optional
    cbTableName: int16,  # SHORT
    szTableType: ptr uint8,  # BYTE* optional
    cbTableType: int16  # SHORT
): int16 {.importc: "SQLTablesA", stdcall, dynlib: "ODBC32.dll".}
pragma(lib, "odbc32");
extern(Windows)
short SQLTablesA(
    void* hstmt,   // void* in/out
    ubyte* szCatalogName,   // BYTE* optional
    short cbCatalogName,   // SHORT
    ubyte* szSchemaName,   // BYTE* optional
    short cbSchemaName,   // SHORT
    ubyte* szTableName,   // BYTE* optional
    short cbTableName,   // SHORT
    ubyte* szTableType,   // BYTE* optional
    short cbTableType   // SHORT
);
ccall((:SQLTablesA, "ODBC32.dll"), stdcall, Int16,
      (Ptr{Cvoid}, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16),
      hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
# hstmt : void* in/out -> Ptr{Cvoid}
# szCatalogName : BYTE* optional -> Ptr{UInt8}
# cbCatalogName : SHORT -> Int16
# szSchemaName : BYTE* optional -> Ptr{UInt8}
# cbSchemaName : SHORT -> Int16
# szTableName : BYTE* optional -> Ptr{UInt8}
# cbTableName : SHORT -> Int16
# szTableType : BYTE* optional -> Ptr{UInt8}
# cbTableType : SHORT -> Int16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int16_t SQLTablesA(
    void* hstmt,
    uint8_t* szCatalogName,
    int16_t cbCatalogName,
    uint8_t* szSchemaName,
    int16_t cbSchemaName,
    uint8_t* szTableName,
    int16_t cbTableName,
    uint8_t* szTableType,
    int16_t cbTableType);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
-- hstmt : void* in/out
-- szCatalogName : BYTE* optional
-- cbCatalogName : SHORT
-- szSchemaName : BYTE* optional
-- cbSchemaName : SHORT
-- szTableName : BYTE* optional
-- cbTableName : SHORT
-- szTableType : BYTE* optional
-- cbTableType : SHORT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLTablesA = lib.func('__stdcall', 'SQLTablesA', 'int16_t', ['void *', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t']);
// SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
// hstmt : void* in/out -> 'void *'
// szCatalogName : BYTE* optional -> 'uint8_t *'
// cbCatalogName : SHORT -> 'int16_t'
// szSchemaName : BYTE* optional -> 'uint8_t *'
// cbSchemaName : SHORT -> 'int16_t'
// szTableName : BYTE* optional -> 'uint8_t *'
// cbTableName : SHORT -> 'int16_t'
// szTableType : BYTE* optional -> 'uint8_t *'
// cbTableType : SHORT -> 'int16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ODBC32.dll", {
  SQLTablesA: { parameters: ["pointer", "pointer", "i16", "pointer", "i16", "pointer", "i16", "pointer", "i16"], result: "i16" },
});
// lib.symbols.SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
// hstmt : void* in/out -> "pointer"
// szCatalogName : BYTE* optional -> "pointer"
// cbCatalogName : SHORT -> "i16"
// szSchemaName : BYTE* optional -> "pointer"
// cbSchemaName : SHORT -> "i16"
// szTableName : BYTE* optional -> "pointer"
// cbTableName : SHORT -> "i16"
// szTableType : BYTE* optional -> "pointer"
// cbTableType : SHORT -> "i16"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int16_t SQLTablesA(
    void* hstmt,
    uint8_t* szCatalogName,
    int16_t cbCatalogName,
    uint8_t* szSchemaName,
    int16_t cbSchemaName,
    uint8_t* szTableName,
    int16_t cbTableName,
    uint8_t* szTableType,
    int16_t cbTableType);
C, "ODBC32.dll");
// $ffi->SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType);
// hstmt : void* in/out
// szCatalogName : BYTE* optional
// cbCatalogName : SHORT
// szSchemaName : BYTE* optional
// cbSchemaName : SHORT
// szTableName : BYTE* optional
// cbTableName : SHORT
// szTableType : BYTE* optional
// cbTableType : SHORT
// 構造体/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 SQLTablesA(
        Pointer hstmt,   // void* in/out
        byte[] szCatalogName,   // BYTE* optional
        short cbCatalogName,   // SHORT
        byte[] szSchemaName,   // BYTE* optional
        short cbSchemaName,   // SHORT
        byte[] szTableName,   // BYTE* optional
        short cbTableName,   // SHORT
        byte[] szTableType,   // BYTE* optional
        short cbTableType   // SHORT
    );
}
@[Link("odbc32")]
lib LibODBC32
  fun SQLTablesA = SQLTablesA(
    hstmt : Void*,   # void* in/out
    szCatalogName : UInt8*,   # BYTE* optional
    cbCatalogName : Int16,   # SHORT
    szSchemaName : UInt8*,   # BYTE* optional
    cbSchemaName : Int16,   # SHORT
    szTableName : UInt8*,   # BYTE* optional
    cbTableName : Int16,   # SHORT
    szTableType : UInt8*,   # BYTE* optional
    cbTableType : Int16   # SHORT
  ) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SQLTablesANative = Int16 Function(Pointer<Void>, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16);
typedef SQLTablesADart = int Function(Pointer<Void>, Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint8>, int);
final SQLTablesA = DynamicLibrary.open('ODBC32.dll')
    .lookupFunction<SQLTablesANative, SQLTablesADart>('SQLTablesA');
// hstmt : void* in/out -> Pointer<Void>
// szCatalogName : BYTE* optional -> Pointer<Uint8>
// cbCatalogName : SHORT -> Int16
// szSchemaName : BYTE* optional -> Pointer<Uint8>
// cbSchemaName : SHORT -> Int16
// szTableName : BYTE* optional -> Pointer<Uint8>
// cbTableName : SHORT -> Int16
// szTableType : BYTE* optional -> Pointer<Uint8>
// cbTableType : SHORT -> Int16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SQLTablesA(
  hstmt: Pointer;   // void* in/out
  szCatalogName: Pointer;   // BYTE* optional
  cbCatalogName: Smallint;   // SHORT
  szSchemaName: Pointer;   // BYTE* optional
  cbSchemaName: Smallint;   // SHORT
  szTableName: Pointer;   // BYTE* optional
  cbTableName: Smallint;   // SHORT
  szTableType: Pointer;   // BYTE* optional
  cbTableType: Smallint   // SHORT
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLTablesA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SQLTablesA"
  c_SQLTablesA :: Ptr () -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- szCatalogName : BYTE* optional -> Ptr Word8
-- cbCatalogName : SHORT -> Int16
-- szSchemaName : BYTE* optional -> Ptr Word8
-- cbSchemaName : SHORT -> Int16
-- szTableName : BYTE* optional -> Ptr Word8
-- cbTableName : SHORT -> Int16
-- szTableType : BYTE* optional -> Ptr Word8
-- cbTableType : SHORT -> Int16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sqltablesa =
  foreign "SQLTablesA"
    ((ptr void) @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* szCatalogName : BYTE* optional -> (ptr uint8_t) *)
(* cbCatalogName : SHORT -> int16_t *)
(* szSchemaName : BYTE* optional -> (ptr uint8_t) *)
(* cbSchemaName : SHORT -> int16_t *)
(* szTableName : BYTE* optional -> (ptr uint8_t) *)
(* cbTableName : SHORT -> int16_t *)
(* szTableType : BYTE* optional -> (ptr uint8_t) *)
(* cbTableType : SHORT -> int16_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)

(cffi:defcfun ("SQLTablesA" sqltables-a :convention :stdcall) :int16
  (hstmt :pointer)   ; void* in/out
  (sz-catalog-name :pointer)   ; BYTE* optional
  (cb-catalog-name :int16)   ; SHORT
  (sz-schema-name :pointer)   ; BYTE* optional
  (cb-schema-name :int16)   ; SHORT
  (sz-table-name :pointer)   ; BYTE* optional
  (cb-table-name :int16)   ; SHORT
  (sz-table-type :pointer)   ; BYTE* optional
  (cb-table-type :int16))   ; SHORT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLTablesA = Win32::API::More->new('ODBC32',
    'short SQLTablesA(LPVOID hstmt, LPVOID szCatalogName, short cbCatalogName, LPVOID szSchemaName, short cbSchemaName, LPVOID szTableName, short cbTableName, LPVOID szTableType, short cbTableType)');
# my $ret = $SQLTablesA->Call($hstmt, $szCatalogName, $cbCatalogName, $szSchemaName, $cbSchemaName, $szTableName, $cbTableName, $szTableType, $cbTableType);
# hstmt : void* in/out -> LPVOID
# szCatalogName : BYTE* optional -> LPVOID
# cbCatalogName : SHORT -> short
# szSchemaName : BYTE* optional -> LPVOID
# cbSchemaName : SHORT -> short
# szTableName : BYTE* optional -> LPVOID
# cbTableName : SHORT -> short
# szTableType : BYTE* optional -> LPVOID
# cbTableType : SHORT -> short
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い