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