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

SQLGetCursorName

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

シグネチャ

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

SHORT SQLGetCursorName(
    void* StatementHandle,
    BYTE* CursorName,   // optional
    SHORT BufferLength,
    SHORT* NameLengthPtr   // optional
);

パラメーター

名前方向説明
StatementHandlevoid*inoutカーソル名を取得する対象のステートメントハンドル。
CursorNameBYTE*outoptionalカーソル名文字列を受け取るバッファ。ANSI文字列。
BufferLengthSHORTinCursorNameバッファの文字数長。
NameLengthPtrSHORT*outoptional実際のカーソル名の文字数を受け取るポインタ。NULL可。

戻り値の型: SHORT

各言語での呼び出し定義

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

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

SQLGetCursorName = ctypes.windll.odbc32.SQLGetCursorName
SQLGetCursorName.restype = ctypes.c_short
SQLGetCursorName.argtypes = [
    ctypes.POINTER(None),  # StatementHandle : void* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # CursorName : BYTE* optional, out
    ctypes.c_short,  # BufferLength : SHORT
    ctypes.POINTER(ctypes.c_short),  # NameLengthPtr : SHORT* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLGetCursorName = Fiddle::Function.new(
  lib['SQLGetCursorName'],
  [
    Fiddle::TYPE_VOIDP,  # StatementHandle : void* in/out
    Fiddle::TYPE_VOIDP,  # CursorName : BYTE* optional, out
    Fiddle::TYPE_SHORT,  # BufferLength : SHORT
    Fiddle::TYPE_VOIDP,  # NameLengthPtr : SHORT* optional, out
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLGetCursorName(
        StatementHandle: *mut (),  // void* in/out
        CursorName: *mut u8,  // BYTE* optional, out
        BufferLength: i16,  // SHORT
        NameLengthPtr: *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 SQLGetCursorName(IntPtr StatementHandle, IntPtr CursorName, short BufferLength, IntPtr NameLengthPtr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetCursorName' -Namespace Win32 -PassThru
# $api::SQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLengthPtr)
#uselib "ODBC32.dll"
#func global SQLGetCursorName "SQLGetCursorName" sptr, sptr, sptr, sptr
; SQLGetCursorName StatementHandle, varptr(CursorName), BufferLength, varptr(NameLengthPtr)   ; 戻り値は stat
; StatementHandle : void* in/out -> "sptr"
; CursorName : BYTE* optional, out -> "sptr"
; BufferLength : SHORT -> "sptr"
; NameLengthPtr : SHORT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLGetCursorName "SQLGetCursorName" sptr, var, int, var
; res = SQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLengthPtr)
; StatementHandle : void* in/out -> "sptr"
; CursorName : BYTE* optional, out -> "var"
; BufferLength : SHORT -> "int"
; NameLengthPtr : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLGetCursorName(void* StatementHandle, BYTE* CursorName, SHORT BufferLength, SHORT* NameLengthPtr)
#uselib "ODBC32.dll"
#cfunc global SQLGetCursorName "SQLGetCursorName" intptr, var, int, var
; res = SQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLengthPtr)
; StatementHandle : void* in/out -> "intptr"
; CursorName : BYTE* optional, out -> "var"
; BufferLength : SHORT -> "int"
; NameLengthPtr : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLGetCursorName = odbc32.NewProc("SQLGetCursorName")
)

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

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

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

let sqlgetcursorname =
  foreign "SQLGetCursorName"
    ((ptr void) @-> (ptr uint8_t) @-> int16_t @-> (ptr int16_t) @-> returning int16_t)
(* StatementHandle : void* in/out -> (ptr void) *)
(* CursorName : BYTE* optional, out -> (ptr uint8_t) *)
(* BufferLength : SHORT -> int16_t *)
(* NameLengthPtr : 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 ("SQLGetCursorName" sqlget-cursor-name :convention :stdcall) :int16
  (statement-handle :pointer)   ; void* in/out
  (cursor-name :pointer)   ; BYTE* optional, out
  (buffer-length :int16)   ; SHORT
  (name-length-ptr :pointer))   ; SHORT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLGetCursorName = Win32::API::More->new('ODBC32',
    'short SQLGetCursorName(LPVOID StatementHandle, LPVOID CursorName, short BufferLength, LPVOID NameLengthPtr)');
# my $ret = $SQLGetCursorName->Call($StatementHandle, $CursorName, $BufferLength, $NameLengthPtr);
# StatementHandle : void* in/out -> LPVOID
# CursorName : BYTE* optional, out -> LPVOID
# BufferLength : SHORT -> short
# NameLengthPtr : SHORT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い