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