Win32 API 日本語リファレンス
ホームSystem.Search › SQLBrowseConnect

SQLBrowseConnect

関数
接続に必要な属性を反復的に取得しながら接続する。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLBrowseConnect(
    void* hdbc,
    BYTE* szConnStrIn,
    SHORT cchConnStrIn,
    BYTE* szConnStrOut,   // optional
    SHORT cchConnStrOutMax,
    SHORT* pcchConnStrOut   // optional
);

パラメーター

名前方向
hdbcvoid*inout
szConnStrInBYTE*in
cchConnStrInSHORTin
szConnStrOutBYTE*outoptional
cchConnStrOutMaxSHORTin
pcchConnStrOutSHORT*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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // SHORT
function 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)。