ホーム › System.Search › SQLExecDirectW
SQLExecDirectW
関数SQL文を準備せず直接実行する(Unicode)。
シグネチャ
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLExecDirectW(
void* hstmt,
WORD* szSqlStr, // optional
INT TextLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hstmt | void* | inout |
| szSqlStr | WORD* | inoptional |
| TextLength | INT | in |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLExecDirectW(
void* hstmt,
WORD* szSqlStr, // optional
INT TextLength
);[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLExecDirectW(
IntPtr hstmt, // void* in/out
IntPtr szSqlStr, // WORD* optional
int TextLength // INT
);<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLExecDirectW(
hstmt As IntPtr, ' void* in/out
szSqlStr As IntPtr, ' WORD* optional
TextLength As Integer ' INT
) As Short
End Function' hstmt : void* in/out
' szSqlStr : WORD* optional
' TextLength : INT
Declare PtrSafe Function SQLExecDirectW Lib "odbc32" ( _
ByVal hstmt As LongPtr, _
ByVal szSqlStr As LongPtr, _
ByVal TextLength 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
SQLExecDirectW = ctypes.windll.odbc32.SQLExecDirectW
SQLExecDirectW.restype = ctypes.c_short
SQLExecDirectW.argtypes = [
ctypes.POINTER(None), # hstmt : void* in/out
ctypes.POINTER(ctypes.c_ushort), # szSqlStr : WORD* optional
ctypes.c_int, # TextLength : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLExecDirectW = Fiddle::Function.new(
lib['SQLExecDirectW'],
[
Fiddle::TYPE_VOIDP, # hstmt : void* in/out
Fiddle::TYPE_VOIDP, # szSqlStr : WORD* optional
Fiddle::TYPE_INT, # TextLength : INT
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbc32")]
extern "system" {
fn SQLExecDirectW(
hstmt: *mut (), // void* in/out
szSqlStr: *mut u16, // WORD* optional
TextLength: i32 // INT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode)]
public static extern short SQLExecDirectW(IntPtr hstmt, IntPtr szSqlStr, int TextLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLExecDirectW' -Namespace Win32 -PassThru
# $api::SQLExecDirectW(hstmt, szSqlStr, TextLength)#uselib "ODBC32.dll"
#func global SQLExecDirectW "SQLExecDirectW" wptr, wptr, wptr
; SQLExecDirectW hstmt, varptr(szSqlStr), TextLength ; 戻り値は stat
; hstmt : void* in/out -> "wptr"
; szSqlStr : WORD* optional -> "wptr"
; TextLength : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLExecDirectW "SQLExecDirectW" sptr, var, int ; res = SQLExecDirectW(hstmt, szSqlStr, TextLength) ; hstmt : void* in/out -> "sptr" ; szSqlStr : WORD* optional -> "var" ; TextLength : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLExecDirectW "SQLExecDirectW" sptr, sptr, int ; res = SQLExecDirectW(hstmt, varptr(szSqlStr), TextLength) ; hstmt : void* in/out -> "sptr" ; szSqlStr : WORD* optional -> "sptr" ; TextLength : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLExecDirectW(void* hstmt, WORD* szSqlStr, INT TextLength) #uselib "ODBC32.dll" #cfunc global SQLExecDirectW "SQLExecDirectW" intptr, var, int ; res = SQLExecDirectW(hstmt, szSqlStr, TextLength) ; hstmt : void* in/out -> "intptr" ; szSqlStr : WORD* optional -> "var" ; TextLength : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLExecDirectW(void* hstmt, WORD* szSqlStr, INT TextLength) #uselib "ODBC32.dll" #cfunc global SQLExecDirectW "SQLExecDirectW" intptr, intptr, int ; res = SQLExecDirectW(hstmt, varptr(szSqlStr), TextLength) ; hstmt : void* in/out -> "intptr" ; szSqlStr : WORD* optional -> "intptr" ; TextLength : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLExecDirectW = odbc32.NewProc("SQLExecDirectW")
)
// hstmt (void* in/out), szSqlStr (WORD* optional), TextLength (INT)
r1, _, err := procSQLExecDirectW.Call(
uintptr(hstmt),
uintptr(szSqlStr),
uintptr(TextLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLExecDirectW(
hstmt: Pointer; // void* in/out
szSqlStr: Pointer; // WORD* optional
TextLength: Integer // INT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLExecDirectW';result := DllCall("ODBC32\SQLExecDirectW"
, "Ptr", hstmt ; void* in/out
, "Ptr", szSqlStr ; WORD* optional
, "Int", TextLength ; INT
, "Short") ; return: SHORT●SQLExecDirectW(hstmt, szSqlStr, TextLength) = DLL("ODBC32.dll", "int SQLExecDirectW(void*, void*, int)")
# 呼び出し: SQLExecDirectW(hstmt, szSqlStr, TextLength)
# hstmt : void* in/out -> "void*"
# szSqlStr : WORD* optional -> "void*"
# TextLength : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。