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