ホーム › System.Search › SQLSetDescFieldW
SQLSetDescFieldW
関数記述子レコードの指定フィールドに値を設定する(Unicode)。
シグネチャ
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLSetDescFieldW(
void* DescriptorHandle,
SHORT RecNumber,
SHORT FieldIdentifier,
void* Value,
INT BufferLength
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| DescriptorHandle | void* | inout | フィールドを設定する対象の記述子ハンドル。 |
| RecNumber | SHORT | in | 設定対象のレコード番号。1始まりで指定する。 |
| FieldIdentifier | SHORT | in | 設定するフィールドのID。SQL_DESC_*定数を指定する。 |
| Value | void* | inout | 設定する値。整数または文字列(Unicode)バッファへのポインタ。 |
| BufferLength | INT | in | Valueが文字列の場合のバイト長。整数ならSQL_IS_INTEGER等。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLSetDescFieldW(
void* DescriptorHandle,
SHORT RecNumber,
SHORT FieldIdentifier,
void* Value,
INT BufferLength
);[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLSetDescFieldW(
IntPtr DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short FieldIdentifier, // SHORT
IntPtr Value, // void* in/out
int BufferLength // INT
);<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLSetDescFieldW(
DescriptorHandle As IntPtr, ' void* in/out
RecNumber As Short, ' SHORT
FieldIdentifier As Short, ' SHORT
Value As IntPtr, ' void* in/out
BufferLength As Integer ' INT
) As Short
End Function' DescriptorHandle : void* in/out
' RecNumber : SHORT
' FieldIdentifier : SHORT
' Value : void* in/out
' BufferLength : INT
Declare PtrSafe Function SQLSetDescFieldW Lib "odbc32" ( _
ByVal DescriptorHandle As LongPtr, _
ByVal RecNumber As Integer, _
ByVal FieldIdentifier As Integer, _
ByVal Value As LongPtr, _
ByVal BufferLength As Long) As Integer
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLSetDescFieldW = ctypes.windll.odbc32.SQLSetDescFieldW
SQLSetDescFieldW.restype = ctypes.c_short
SQLSetDescFieldW.argtypes = [
ctypes.POINTER(None), # DescriptorHandle : void* in/out
ctypes.c_short, # RecNumber : SHORT
ctypes.c_short, # FieldIdentifier : SHORT
ctypes.POINTER(None), # Value : void* in/out
ctypes.c_int, # BufferLength : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLSetDescFieldW = Fiddle::Function.new(
lib['SQLSetDescFieldW'],
[
Fiddle::TYPE_VOIDP, # DescriptorHandle : void* in/out
Fiddle::TYPE_SHORT, # RecNumber : SHORT
Fiddle::TYPE_SHORT, # FieldIdentifier : SHORT
Fiddle::TYPE_VOIDP, # Value : void* in/out
Fiddle::TYPE_INT, # BufferLength : INT
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbc32")]
extern "system" {
fn SQLSetDescFieldW(
DescriptorHandle: *mut (), // void* in/out
RecNumber: i16, // SHORT
FieldIdentifier: i16, // SHORT
Value: *mut (), // void* in/out
BufferLength: i32 // INT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode)]
public static extern short SQLSetDescFieldW(IntPtr DescriptorHandle, short RecNumber, short FieldIdentifier, IntPtr Value, int BufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLSetDescFieldW' -Namespace Win32 -PassThru
# $api::SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)#uselib "ODBC32.dll"
#func global SQLSetDescFieldW "SQLSetDescFieldW" wptr, wptr, wptr, wptr, wptr
; SQLSetDescFieldW DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength ; 戻り値は stat
; DescriptorHandle : void* in/out -> "wptr"
; RecNumber : SHORT -> "wptr"
; FieldIdentifier : SHORT -> "wptr"
; Value : void* in/out -> "wptr"
; BufferLength : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ODBC32.dll"
#cfunc global SQLSetDescFieldW "SQLSetDescFieldW" sptr, int, int, sptr, int
; res = SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
; DescriptorHandle : void* in/out -> "sptr"
; RecNumber : SHORT -> "int"
; FieldIdentifier : SHORT -> "int"
; Value : void* in/out -> "sptr"
; BufferLength : INT -> "int"; SHORT SQLSetDescFieldW(void* DescriptorHandle, SHORT RecNumber, SHORT FieldIdentifier, void* Value, INT BufferLength)
#uselib "ODBC32.dll"
#cfunc global SQLSetDescFieldW "SQLSetDescFieldW" intptr, int, int, intptr, int
; res = SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
; DescriptorHandle : void* in/out -> "intptr"
; RecNumber : SHORT -> "int"
; FieldIdentifier : SHORT -> "int"
; Value : void* in/out -> "intptr"
; BufferLength : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLSetDescFieldW = odbc32.NewProc("SQLSetDescFieldW")
)
// DescriptorHandle (void* in/out), RecNumber (SHORT), FieldIdentifier (SHORT), Value (void* in/out), BufferLength (INT)
r1, _, err := procSQLSetDescFieldW.Call(
uintptr(DescriptorHandle),
uintptr(RecNumber),
uintptr(FieldIdentifier),
uintptr(Value),
uintptr(BufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLSetDescFieldW(
DescriptorHandle: Pointer; // void* in/out
RecNumber: Smallint; // SHORT
FieldIdentifier: Smallint; // SHORT
Value: Pointer; // void* in/out
BufferLength: Integer // INT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetDescFieldW';result := DllCall("ODBC32\SQLSetDescFieldW"
, "Ptr", DescriptorHandle ; void* in/out
, "Short", RecNumber ; SHORT
, "Short", FieldIdentifier ; SHORT
, "Ptr", Value ; void* in/out
, "Int", BufferLength ; INT
, "Short") ; return: SHORT●SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength) = DLL("ODBC32.dll", "int SQLSetDescFieldW(void*, int, int, void*, int)")
# 呼び出し: SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
# DescriptorHandle : void* in/out -> "void*"
# RecNumber : SHORT -> "int"
# FieldIdentifier : SHORT -> "int"
# Value : void* in/out -> "void*"
# BufferLength : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "odbc32" fn SQLSetDescFieldW(
DescriptorHandle: ?*anyopaque, // void* in/out
RecNumber: i16, // SHORT
FieldIdentifier: i16, // SHORT
Value: ?*anyopaque, // void* in/out
BufferLength: i32 // INT
) callconv(std.os.windows.WINAPI) i16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SQLSetDescFieldW(
DescriptorHandle: pointer, # void* in/out
RecNumber: int16, # SHORT
FieldIdentifier: int16, # SHORT
Value: pointer, # void* in/out
BufferLength: int32 # INT
): int16 {.importc: "SQLSetDescFieldW", stdcall, dynlib: "ODBC32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "odbc32");
extern(Windows)
short SQLSetDescFieldW(
void* DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short FieldIdentifier, // SHORT
void* Value, // void* in/out
int BufferLength // INT
);ccall((:SQLSetDescFieldW, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Int16, Int16, Ptr{Cvoid}, Int32),
DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
# DescriptorHandle : void* in/out -> Ptr{Cvoid}
# RecNumber : SHORT -> Int16
# FieldIdentifier : SHORT -> Int16
# Value : void* in/out -> Ptr{Cvoid}
# BufferLength : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLSetDescFieldW(
void* DescriptorHandle,
int16_t RecNumber,
int16_t FieldIdentifier,
void* Value,
int32_t BufferLength);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
-- DescriptorHandle : void* in/out
-- RecNumber : SHORT
-- FieldIdentifier : SHORT
-- Value : void* in/out
-- BufferLength : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLSetDescFieldW = lib.func('__stdcall', 'SQLSetDescFieldW', 'int16_t', ['void *', 'int16_t', 'int16_t', 'void *', 'int32_t']);
// SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
// DescriptorHandle : void* in/out -> 'void *'
// RecNumber : SHORT -> 'int16_t'
// FieldIdentifier : SHORT -> 'int16_t'
// Value : void* in/out -> 'void *'
// BufferLength : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLSetDescFieldW: { parameters: ["pointer", "i16", "i16", "pointer", "i32"], result: "i16" },
});
// lib.symbols.SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
// DescriptorHandle : void* in/out -> "pointer"
// RecNumber : SHORT -> "i16"
// FieldIdentifier : SHORT -> "i16"
// Value : void* in/out -> "pointer"
// BufferLength : INT -> "i32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLSetDescFieldW(
void* DescriptorHandle,
int16_t RecNumber,
int16_t FieldIdentifier,
void* Value,
int32_t BufferLength);
C, "ODBC32.dll");
// $ffi->SQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
// DescriptorHandle : void* in/out
// RecNumber : SHORT
// FieldIdentifier : SHORT
// Value : void* in/out
// BufferLength : INT
// 構造体/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.UNICODE_OPTIONS);
short SQLSetDescFieldW(
Pointer DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short FieldIdentifier, // SHORT
Pointer Value, // void* in/out
int BufferLength // INT
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("odbc32")]
lib LibODBC32
fun SQLSetDescFieldW = SQLSetDescFieldW(
DescriptorHandle : Void*, # void* in/out
RecNumber : Int16, # SHORT
FieldIdentifier : Int16, # SHORT
Value : Void*, # void* in/out
BufferLength : Int32 # INT
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLSetDescFieldWNative = Int16 Function(Pointer<Void>, Int16, Int16, Pointer<Void>, Int32);
typedef SQLSetDescFieldWDart = int Function(Pointer<Void>, int, int, Pointer<Void>, int);
final SQLSetDescFieldW = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLSetDescFieldWNative, SQLSetDescFieldWDart>('SQLSetDescFieldW');
// DescriptorHandle : void* in/out -> Pointer<Void>
// RecNumber : SHORT -> Int16
// FieldIdentifier : SHORT -> Int16
// Value : void* in/out -> Pointer<Void>
// BufferLength : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLSetDescFieldW(
DescriptorHandle: Pointer; // void* in/out
RecNumber: Smallint; // SHORT
FieldIdentifier: Smallint; // SHORT
Value: Pointer; // void* in/out
BufferLength: Integer // INT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetDescFieldW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLSetDescFieldW"
c_SQLSetDescFieldW :: Ptr () -> Int16 -> Int16 -> Ptr () -> Int32 -> IO Int16
-- DescriptorHandle : void* in/out -> Ptr ()
-- RecNumber : SHORT -> Int16
-- FieldIdentifier : SHORT -> Int16
-- Value : void* in/out -> Ptr ()
-- BufferLength : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlsetdescfieldw =
foreign "SQLSetDescFieldW"
((ptr void) @-> int16_t @-> int16_t @-> (ptr void) @-> int32_t @-> returning int16_t)
(* DescriptorHandle : void* in/out -> (ptr void) *)
(* RecNumber : SHORT -> int16_t *)
(* FieldIdentifier : SHORT -> int16_t *)
(* Value : void* in/out -> (ptr void) *)
(* BufferLength : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLSetDescFieldW" sqlset-desc-field-w :convention :stdcall) :int16
(descriptor-handle :pointer) ; void* in/out
(rec-number :int16) ; SHORT
(field-identifier :int16) ; SHORT
(value :pointer) ; void* in/out
(buffer-length :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLSetDescFieldW = Win32::API::More->new('ODBC32',
'short SQLSetDescFieldW(LPVOID DescriptorHandle, short RecNumber, short FieldIdentifier, LPVOID Value, int BufferLength)');
# my $ret = $SQLSetDescFieldW->Call($DescriptorHandle, $RecNumber, $FieldIdentifier, $Value, $BufferLength);
# DescriptorHandle : void* in/out -> LPVOID
# RecNumber : SHORT -> short
# FieldIdentifier : SHORT -> short
# Value : void* in/out -> LPVOID
# BufferLength : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。