ホーム › System.Search › SQLSetCursorNameA
SQLSetCursorNameA
関数ステートメントに関連付けるカーソル名を設定する。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLSetCursorNameA(
void* hstmt,
BYTE* szCursor,
SHORT cbCursor
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hstmt | void* | inout | ODBCのステートメントハンドル。カーソル名設定対象。 |
| szCursor | BYTE* | in | 設定するカーソル名。 |
| cbCursor | SHORT | in | szCursorの文字数。SQL_NTSでNUL終端とみなす。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLSetCursorNameA(
void* hstmt,
BYTE* szCursor,
SHORT cbCursor
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLSetCursorNameA(
IntPtr hstmt, // void* in/out
IntPtr szCursor, // BYTE*
short cbCursor // SHORT
);<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLSetCursorNameA(
hstmt As IntPtr, ' void* in/out
szCursor As IntPtr, ' BYTE*
cbCursor As Short ' SHORT
) As Short
End Function' hstmt : void* in/out
' szCursor : BYTE*
' cbCursor : SHORT
Declare PtrSafe Function SQLSetCursorNameA Lib "odbc32" ( _
ByVal hstmt As LongPtr, _
ByVal szCursor As LongPtr, _
ByVal cbCursor As Integer) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLSetCursorNameA = ctypes.windll.odbc32.SQLSetCursorNameA
SQLSetCursorNameA.restype = ctypes.c_short
SQLSetCursorNameA.argtypes = [
ctypes.POINTER(None), # hstmt : void* in/out
ctypes.POINTER(ctypes.c_ubyte), # szCursor : BYTE*
ctypes.c_short, # cbCursor : SHORT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLSetCursorNameA = Fiddle::Function.new(
lib['SQLSetCursorNameA'],
[
Fiddle::TYPE_VOIDP, # hstmt : void* in/out
Fiddle::TYPE_VOIDP, # szCursor : BYTE*
Fiddle::TYPE_SHORT, # cbCursor : SHORT
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLSetCursorNameA(
hstmt: *mut (), // void* in/out
szCursor: *mut u8, // BYTE*
cbCursor: i16 // SHORT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLSetCursorNameA(IntPtr hstmt, IntPtr szCursor, short cbCursor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLSetCursorNameA' -Namespace Win32 -PassThru
# $api::SQLSetCursorNameA(hstmt, szCursor, cbCursor)#uselib "ODBC32.dll"
#func global SQLSetCursorNameA "SQLSetCursorNameA" sptr, sptr, sptr
; SQLSetCursorNameA hstmt, varptr(szCursor), cbCursor ; 戻り値は stat
; hstmt : void* in/out -> "sptr"
; szCursor : BYTE* -> "sptr"
; cbCursor : SHORT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLSetCursorNameA "SQLSetCursorNameA" sptr, var, int ; res = SQLSetCursorNameA(hstmt, szCursor, cbCursor) ; hstmt : void* in/out -> "sptr" ; szCursor : BYTE* -> "var" ; cbCursor : SHORT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLSetCursorNameA "SQLSetCursorNameA" sptr, sptr, int ; res = SQLSetCursorNameA(hstmt, varptr(szCursor), cbCursor) ; hstmt : void* in/out -> "sptr" ; szCursor : BYTE* -> "sptr" ; cbCursor : SHORT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLSetCursorNameA(void* hstmt, BYTE* szCursor, SHORT cbCursor) #uselib "ODBC32.dll" #cfunc global SQLSetCursorNameA "SQLSetCursorNameA" intptr, var, int ; res = SQLSetCursorNameA(hstmt, szCursor, cbCursor) ; hstmt : void* in/out -> "intptr" ; szCursor : BYTE* -> "var" ; cbCursor : SHORT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLSetCursorNameA(void* hstmt, BYTE* szCursor, SHORT cbCursor) #uselib "ODBC32.dll" #cfunc global SQLSetCursorNameA "SQLSetCursorNameA" intptr, intptr, int ; res = SQLSetCursorNameA(hstmt, varptr(szCursor), cbCursor) ; hstmt : void* in/out -> "intptr" ; szCursor : BYTE* -> "intptr" ; cbCursor : SHORT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLSetCursorNameA = odbc32.NewProc("SQLSetCursorNameA")
)
// hstmt (void* in/out), szCursor (BYTE*), cbCursor (SHORT)
r1, _, err := procSQLSetCursorNameA.Call(
uintptr(hstmt),
uintptr(szCursor),
uintptr(cbCursor),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLSetCursorNameA(
hstmt: Pointer; // void* in/out
szCursor: Pointer; // BYTE*
cbCursor: Smallint // SHORT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetCursorNameA';result := DllCall("ODBC32\SQLSetCursorNameA"
, "Ptr", hstmt ; void* in/out
, "Ptr", szCursor ; BYTE*
, "Short", cbCursor ; SHORT
, "Short") ; return: SHORT●SQLSetCursorNameA(hstmt, szCursor, cbCursor) = DLL("ODBC32.dll", "int SQLSetCursorNameA(void*, void*, int)")
# 呼び出し: SQLSetCursorNameA(hstmt, szCursor, cbCursor)
# hstmt : void* in/out -> "void*"
# szCursor : BYTE* -> "void*"
# cbCursor : SHORT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLSetCursorNameA(
hstmt: ?*anyopaque, // void* in/out
szCursor: [*c]u8, // BYTE*
cbCursor: i16 // SHORT
) callconv(std.os.windows.WINAPI) i16;proc SQLSetCursorNameA(
hstmt: pointer, # void* in/out
szCursor: ptr uint8, # BYTE*
cbCursor: int16 # SHORT
): int16 {.importc: "SQLSetCursorNameA", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLSetCursorNameA(
void* hstmt, // void* in/out
ubyte* szCursor, // BYTE*
short cbCursor // SHORT
);ccall((:SQLSetCursorNameA, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Ptr{UInt8}, Int16),
hstmt, szCursor, cbCursor)
# hstmt : void* in/out -> Ptr{Cvoid}
# szCursor : BYTE* -> Ptr{UInt8}
# cbCursor : SHORT -> Int16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLSetCursorNameA(
void* hstmt,
uint8_t* szCursor,
int16_t cbCursor);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLSetCursorNameA(hstmt, szCursor, cbCursor)
-- hstmt : void* in/out
-- szCursor : BYTE*
-- cbCursor : SHORT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLSetCursorNameA = lib.func('__stdcall', 'SQLSetCursorNameA', 'int16_t', ['void *', 'uint8_t *', 'int16_t']);
// SQLSetCursorNameA(hstmt, szCursor, cbCursor)
// hstmt : void* in/out -> 'void *'
// szCursor : BYTE* -> 'uint8_t *'
// cbCursor : SHORT -> 'int16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLSetCursorNameA: { parameters: ["pointer", "pointer", "i16"], result: "i16" },
});
// lib.symbols.SQLSetCursorNameA(hstmt, szCursor, cbCursor)
// hstmt : void* in/out -> "pointer"
// szCursor : BYTE* -> "pointer"
// cbCursor : SHORT -> "i16"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLSetCursorNameA(
void* hstmt,
uint8_t* szCursor,
int16_t cbCursor);
C, "ODBC32.dll");
// $ffi->SQLSetCursorNameA(hstmt, szCursor, cbCursor);
// hstmt : void* in/out
// szCursor : BYTE*
// cbCursor : 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 SQLSetCursorNameA(
Pointer hstmt, // void* in/out
byte[] szCursor, // BYTE*
short cbCursor // SHORT
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLSetCursorNameA = SQLSetCursorNameA(
hstmt : Void*, # void* in/out
szCursor : UInt8*, # BYTE*
cbCursor : 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 SQLSetCursorNameANative = Int16 Function(Pointer<Void>, Pointer<Uint8>, Int16);
typedef SQLSetCursorNameADart = int Function(Pointer<Void>, Pointer<Uint8>, int);
final SQLSetCursorNameA = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLSetCursorNameANative, SQLSetCursorNameADart>('SQLSetCursorNameA');
// hstmt : void* in/out -> Pointer<Void>
// szCursor : BYTE* -> Pointer<Uint8>
// cbCursor : SHORT -> Int16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLSetCursorNameA(
hstmt: Pointer; // void* in/out
szCursor: Pointer; // BYTE*
cbCursor: Smallint // SHORT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetCursorNameA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLSetCursorNameA"
c_SQLSetCursorNameA :: Ptr () -> Ptr Word8 -> Int16 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- szCursor : BYTE* -> Ptr Word8
-- cbCursor : SHORT -> Int16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlsetcursornamea =
foreign "SQLSetCursorNameA"
((ptr void) @-> (ptr uint8_t) @-> int16_t @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* szCursor : BYTE* -> (ptr uint8_t) *)
(* cbCursor : 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 ("SQLSetCursorNameA" sqlset-cursor-name-a :convention :stdcall) :int16
(hstmt :pointer) ; void* in/out
(sz-cursor :pointer) ; BYTE*
(cb-cursor :int16)) ; SHORT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLSetCursorNameA = Win32::API::More->new('ODBC32',
'short SQLSetCursorNameA(LPVOID hstmt, LPVOID szCursor, short cbCursor)');
# my $ret = $SQLSetCursorNameA->Call($hstmt, $szCursor, $cbCursor);
# hstmt : void* in/out -> LPVOID
# szCursor : BYTE* -> LPVOID
# cbCursor : SHORT -> short
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SQLSetCursorNameW (Unicode版) — ステートメントにカーソル名を設定する(Unicode)。