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

SQLGetCursorNameA

関数
ステートメントのカーソル名を取得する(ANSI)。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

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

SHORT SQLGetCursorNameA(
    void* hstmt,
    BYTE* szCursor,   // optional
    SHORT cbCursorMax,
    SHORT* pcbCursor   // optional
);

パラメーター

名前方向説明
hstmtvoid*inoutODBCのステートメントハンドル。カーソル名取得対象。
szCursorBYTE*outoptionalカーソル名を受け取るバッファ。出力用。
cbCursorMaxSHORTinszCursorバッファのバイト長。
pcbCursorSHORT*outoptional実際に返されたカーソル名のバイト長を受け取るポインタ。

戻り値の型: SHORT

各言語での呼び出し定義

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

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

SQLGetCursorNameA = ctypes.windll.odbc32.SQLGetCursorNameA
SQLGetCursorNameA.restype = ctypes.c_short
SQLGetCursorNameA.argtypes = [
    ctypes.POINTER(None),  # hstmt : void* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # szCursor : BYTE* optional, out
    ctypes.c_short,  # cbCursorMax : SHORT
    ctypes.POINTER(ctypes.c_short),  # pcbCursor : SHORT* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLGetCursorNameA = odbc32.NewProc("SQLGetCursorNameA")
)

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

extern "odbc32" fn SQLGetCursorNameA(
    hstmt: ?*anyopaque, // void* in/out
    szCursor: [*c]u8, // BYTE* optional, out
    cbCursorMax: i16, // SHORT
    pcbCursor: [*c]i16 // SHORT* optional, out
) callconv(std.os.windows.WINAPI) i16;
proc SQLGetCursorNameA(
    hstmt: pointer,  # void* in/out
    szCursor: ptr uint8,  # BYTE* optional, out
    cbCursorMax: int16,  # SHORT
    pcbCursor: ptr int16  # SHORT* optional, out
): int16 {.importc: "SQLGetCursorNameA", stdcall, dynlib: "ODBC32.dll".}
pragma(lib, "odbc32");
extern(Windows)
short SQLGetCursorNameA(
    void* hstmt,   // void* in/out
    ubyte* szCursor,   // BYTE* optional, out
    short cbCursorMax,   // SHORT
    short* pcbCursor   // SHORT* optional, out
);
ccall((:SQLGetCursorNameA, "ODBC32.dll"), stdcall, Int16,
      (Ptr{Cvoid}, Ptr{UInt8}, Int16, Ptr{Int16}),
      hstmt, szCursor, cbCursorMax, pcbCursor)
# hstmt : void* in/out -> Ptr{Cvoid}
# szCursor : BYTE* optional, out -> Ptr{UInt8}
# cbCursorMax : SHORT -> Int16
# pcbCursor : SHORT* optional, out -> Ptr{Int16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int16_t SQLGetCursorNameA(
    void* hstmt,
    uint8_t* szCursor,
    int16_t cbCursorMax,
    int16_t* pcbCursor);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLGetCursorNameA(hstmt, szCursor, cbCursorMax, pcbCursor)
-- hstmt : void* in/out
-- szCursor : BYTE* optional, out
-- cbCursorMax : SHORT
-- pcbCursor : SHORT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLGetCursorNameA = lib.func('__stdcall', 'SQLGetCursorNameA', 'int16_t', ['void *', 'uint8_t *', 'int16_t', 'int16_t *']);
// SQLGetCursorNameA(hstmt, szCursor, cbCursorMax, pcbCursor)
// hstmt : void* in/out -> 'void *'
// szCursor : BYTE* optional, out -> 'uint8_t *'
// cbCursorMax : SHORT -> 'int16_t'
// pcbCursor : SHORT* optional, out -> 'int16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ODBC32.dll", {
  SQLGetCursorNameA: { parameters: ["pointer", "pointer", "i16", "pointer"], result: "i16" },
});
// lib.symbols.SQLGetCursorNameA(hstmt, szCursor, cbCursorMax, pcbCursor)
// hstmt : void* in/out -> "pointer"
// szCursor : BYTE* optional, out -> "pointer"
// cbCursorMax : SHORT -> "i16"
// pcbCursor : SHORT* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int16_t SQLGetCursorNameA(
    void* hstmt,
    uint8_t* szCursor,
    int16_t cbCursorMax,
    int16_t* pcbCursor);
C, "ODBC32.dll");
// $ffi->SQLGetCursorNameA(hstmt, szCursor, cbCursorMax, pcbCursor);
// hstmt : void* in/out
// szCursor : BYTE* optional, out
// cbCursorMax : SHORT
// pcbCursor : SHORT* 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 SQLGetCursorNameA(
        Pointer hstmt,   // void* in/out
        byte[] szCursor,   // BYTE* optional, out
        short cbCursorMax,   // SHORT
        ShortByReference pcbCursor   // SHORT* optional, out
    );
}
@[Link("odbc32")]
lib LibODBC32
  fun SQLGetCursorNameA = SQLGetCursorNameA(
    hstmt : Void*,   # void* in/out
    szCursor : UInt8*,   # BYTE* optional, out
    cbCursorMax : Int16,   # SHORT
    pcbCursor : Int16*   # SHORT* 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 SQLGetCursorNameANative = Int16 Function(Pointer<Void>, Pointer<Uint8>, Int16, Pointer<Int16>);
typedef SQLGetCursorNameADart = int Function(Pointer<Void>, Pointer<Uint8>, int, Pointer<Int16>);
final SQLGetCursorNameA = DynamicLibrary.open('ODBC32.dll')
    .lookupFunction<SQLGetCursorNameANative, SQLGetCursorNameADart>('SQLGetCursorNameA');
// hstmt : void* in/out -> Pointer<Void>
// szCursor : BYTE* optional, out -> Pointer<Uint8>
// cbCursorMax : SHORT -> Int16
// pcbCursor : SHORT* optional, out -> Pointer<Int16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SQLGetCursorNameA(
  hstmt: Pointer;   // void* in/out
  szCursor: Pointer;   // BYTE* optional, out
  cbCursorMax: Smallint;   // SHORT
  pcbCursor: Pointer   // SHORT* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLGetCursorNameA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SQLGetCursorNameA"
  c_SQLGetCursorNameA :: Ptr () -> Ptr Word8 -> Int16 -> Ptr Int16 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- szCursor : BYTE* optional, out -> Ptr Word8
-- cbCursorMax : SHORT -> Int16
-- pcbCursor : SHORT* optional, out -> Ptr Int16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sqlgetcursornamea =
  foreign "SQLGetCursorNameA"
    ((ptr void) @-> (ptr uint8_t) @-> int16_t @-> (ptr int16_t) @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* szCursor : BYTE* optional, out -> (ptr uint8_t) *)
(* cbCursorMax : SHORT -> int16_t *)
(* pcbCursor : SHORT* optional, out -> (ptr int16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)

(cffi:defcfun ("SQLGetCursorNameA" sqlget-cursor-name-a :convention :stdcall) :int16
  (hstmt :pointer)   ; void* in/out
  (sz-cursor :pointer)   ; BYTE* optional, out
  (cb-cursor-max :int16)   ; SHORT
  (pcb-cursor :pointer))   ; SHORT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLGetCursorNameA = Win32::API::More->new('ODBC32',
    'short SQLGetCursorNameA(LPVOID hstmt, LPVOID szCursor, short cbCursorMax, LPVOID pcbCursor)');
# my $ret = $SQLGetCursorNameA->Call($hstmt, $szCursor, $cbCursorMax, $pcbCursor);
# hstmt : void* in/out -> LPVOID
# szCursor : BYTE* optional, out -> LPVOID
# cbCursorMax : SHORT -> short
# pcbCursor : SHORT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い