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

SQLBrowseConnectW

関数
接続属性を反復取得しながらデータソースに接続する(Unicode)。
DLLODBC32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// ODBC32.dll  (Unicode / -W)
#include <windows.h>

SHORT SQLBrowseConnectW(
    void* hdbc,
    WORD* szConnStrIn,
    SHORT cchConnStrIn,
    WORD* szConnStrOut,   // optional
    SHORT cchConnStrOutMax,
    SHORT* pcchConnStrOut   // optional
);

パラメーター

名前方向
hdbcvoid*inout
szConnStrInWORD*in
cchConnStrInSHORTin
szConnStrOutWORD*outoptional
cchConnStrOutMaxSHORTin
pcchConnStrOutSHORT*outoptional

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll  (Unicode / -W)
#include <windows.h>

SHORT SQLBrowseConnectW(
    void* hdbc,
    WORD* szConnStrIn,
    SHORT cchConnStrIn,
    WORD* szConnStrOut,   // optional
    SHORT cchConnStrOutMax,
    SHORT* pcchConnStrOut   // optional
);
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLBrowseConnectW(
    IntPtr hdbc,   // void* in/out
    ref ushort szConnStrIn,   // WORD*
    short cchConnStrIn,   // SHORT
    IntPtr szConnStrOut,   // WORD* optional, out
    short cchConnStrOutMax,   // SHORT
    IntPtr pcchConnStrOut   // SHORT* optional, out
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLBrowseConnectW(
    hdbc As IntPtr,   ' void* in/out
    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
) As Short
End Function
' hdbc : void* in/out
' szConnStrIn : WORD*
' cchConnStrIn : SHORT
' szConnStrOut : WORD* optional, out
' cchConnStrOutMax : SHORT
' pcchConnStrOut : SHORT* optional, out
Declare PtrSafe Function SQLBrowseConnectW Lib "odbc32" ( _
    ByVal hdbc As LongPtr, _
    ByRef szConnStrIn As Integer, _
    ByVal cchConnStrIn As Integer, _
    ByVal szConnStrOut As LongPtr, _
    ByVal cchConnStrOutMax As Integer, _
    ByVal pcchConnStrOut 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

SQLBrowseConnectW = ctypes.windll.odbc32.SQLBrowseConnectW
SQLBrowseConnectW.restype = ctypes.c_short
SQLBrowseConnectW.argtypes = [
    ctypes.POINTER(None),  # hdbc : void* in/out
    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
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLBrowseConnectW = Fiddle::Function.new(
  lib['SQLBrowseConnectW'],
  [
    Fiddle::TYPE_VOIDP,  # hdbc : void* in/out
    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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "odbc32")]
extern "system" {
    fn SQLBrowseConnectW(
        hdbc: *mut (),  // void* in/out
        szConnStrIn: *mut u16,  // WORD*
        cchConnStrIn: i16,  // SHORT
        szConnStrOut: *mut u16,  // WORD* 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.Unicode)]
public static extern short SQLBrowseConnectW(IntPtr hdbc, ref ushort szConnStrIn, short cchConnStrIn, IntPtr szConnStrOut, short cchConnStrOutMax, IntPtr pcchConnStrOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLBrowseConnectW' -Namespace Win32 -PassThru
# $api::SQLBrowseConnectW(hdbc, szConnStrIn, cchConnStrIn, szConnStrOut, cchConnStrOutMax, pcchConnStrOut)
#uselib "ODBC32.dll"
#func global SQLBrowseConnectW "SQLBrowseConnectW" wptr, wptr, wptr, wptr, wptr, wptr
; SQLBrowseConnectW hdbc, varptr(szConnStrIn), cchConnStrIn, varptr(szConnStrOut), cchConnStrOutMax, varptr(pcchConnStrOut)   ; 戻り値は stat
; hdbc : void* in/out -> "wptr"
; szConnStrIn : WORD* -> "wptr"
; cchConnStrIn : SHORT -> "wptr"
; szConnStrOut : WORD* optional, out -> "wptr"
; cchConnStrOutMax : SHORT -> "wptr"
; pcchConnStrOut : SHORT* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLBrowseConnectW "SQLBrowseConnectW" sptr, var, int, var, int, var
; res = SQLBrowseConnectW(hdbc, szConnStrIn, cchConnStrIn, szConnStrOut, cchConnStrOutMax, pcchConnStrOut)
; hdbc : void* in/out -> "sptr"
; szConnStrIn : WORD* -> "var"
; cchConnStrIn : SHORT -> "int"
; szConnStrOut : WORD* optional, out -> "var"
; cchConnStrOutMax : SHORT -> "int"
; pcchConnStrOut : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLBrowseConnectW(void* hdbc, WORD* szConnStrIn, SHORT cchConnStrIn, WORD* szConnStrOut, SHORT cchConnStrOutMax, SHORT* pcchConnStrOut)
#uselib "ODBC32.dll"
#cfunc global SQLBrowseConnectW "SQLBrowseConnectW" intptr, var, int, var, int, var
; res = SQLBrowseConnectW(hdbc, szConnStrIn, cchConnStrIn, szConnStrOut, cchConnStrOutMax, pcchConnStrOut)
; hdbc : void* in/out -> "intptr"
; szConnStrIn : WORD* -> "var"
; cchConnStrIn : SHORT -> "int"
; szConnStrOut : WORD* 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")
	procSQLBrowseConnectW = odbc32.NewProc("SQLBrowseConnectW")
)

// hdbc (void* in/out), szConnStrIn (WORD*), cchConnStrIn (SHORT), szConnStrOut (WORD* optional, out), cchConnStrOutMax (SHORT), pcchConnStrOut (SHORT* optional, out)
r1, _, err := procSQLBrowseConnectW.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 SQLBrowseConnectW(
  hdbc: Pointer;   // void* in/out
  szConnStrIn: Pointer;   // WORD*
  cchConnStrIn: Smallint;   // SHORT
  szConnStrOut: Pointer;   // WORD* optional, out
  cchConnStrOutMax: Smallint;   // SHORT
  pcchConnStrOut: Pointer   // SHORT* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLBrowseConnectW';
result := DllCall("ODBC32\SQLBrowseConnectW"
    , "Ptr", hdbc   ; void* in/out
    , "Ptr", szConnStrIn   ; WORD*
    , "Short", cchConnStrIn   ; SHORT
    , "Ptr", szConnStrOut   ; WORD* optional, out
    , "Short", cchConnStrOutMax   ; SHORT
    , "Ptr", pcchConnStrOut   ; SHORT* optional, out
    , "Short")   ; return: SHORT
●SQLBrowseConnectW(hdbc, szConnStrIn, cchConnStrIn, szConnStrOut, cchConnStrOutMax, pcchConnStrOut) = DLL("ODBC32.dll", "int SQLBrowseConnectW(void*, void*, int, void*, int, void*)")
# 呼び出し: SQLBrowseConnectW(hdbc, szConnStrIn, cchConnStrIn, szConnStrOut, cchConnStrOutMax, pcchConnStrOut)
# hdbc : void* in/out -> "void*"
# szConnStrIn : WORD* -> "void*"
# cchConnStrIn : SHORT -> "int"
# szConnStrOut : WORD* optional, out -> "void*"
# cchConnStrOutMax : SHORT -> "int"
# pcchConnStrOut : SHORT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。