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