ホーム › System.Search › SQLInitEnumServers
SQLInitEnumServers
関数SQL Serverインスタンスの列挙を開始しハンドルを返す。
シグネチャ
// odbcbcp.dll
#include <windows.h>
HANDLE SQLInitEnumServers(
LPWSTR pwchServerName,
LPWSTR pwchInstanceName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pwchServerName | LPWSTR | in |
| pwchInstanceName | LPWSTR | in |
戻り値の型: HANDLE
各言語での呼び出し定義
// odbcbcp.dll
#include <windows.h>
HANDLE SQLInitEnumServers(
LPWSTR pwchServerName,
LPWSTR pwchInstanceName
);[DllImport("odbcbcp.dll", ExactSpelling = true)]
static extern IntPtr SQLInitEnumServers(
[MarshalAs(UnmanagedType.LPWStr)] string pwchServerName, // LPWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pwchInstanceName // LPWSTR
);<DllImport("odbcbcp.dll", ExactSpelling:=True)>
Public Shared Function SQLInitEnumServers(
<MarshalAs(UnmanagedType.LPWStr)> pwchServerName As String, ' LPWSTR
<MarshalAs(UnmanagedType.LPWStr)> pwchInstanceName As String ' LPWSTR
) As IntPtr
End Function' pwchServerName : LPWSTR
' pwchInstanceName : LPWSTR
Declare PtrSafe Function SQLInitEnumServers Lib "odbcbcp" ( _
ByVal pwchServerName As LongPtr, _
ByVal pwchInstanceName As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLInitEnumServers = ctypes.windll.odbcbcp.SQLInitEnumServers
SQLInitEnumServers.restype = ctypes.c_void_p
SQLInitEnumServers.argtypes = [
wintypes.LPCWSTR, # pwchServerName : LPWSTR
wintypes.LPCWSTR, # pwchInstanceName : LPWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('odbcbcp.dll')
SQLInitEnumServers = Fiddle::Function.new(
lib['SQLInitEnumServers'],
[
Fiddle::TYPE_VOIDP, # pwchServerName : LPWSTR
Fiddle::TYPE_VOIDP, # pwchInstanceName : LPWSTR
],
Fiddle::TYPE_VOIDP)#[link(name = "odbcbcp")]
extern "system" {
fn SQLInitEnumServers(
pwchServerName: *mut u16, // LPWSTR
pwchInstanceName: *mut u16 // LPWSTR
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("odbcbcp.dll")]
public static extern IntPtr SQLInitEnumServers([MarshalAs(UnmanagedType.LPWStr)] string pwchServerName, [MarshalAs(UnmanagedType.LPWStr)] string pwchInstanceName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'odbcbcp_SQLInitEnumServers' -Namespace Win32 -PassThru
# $api::SQLInitEnumServers(pwchServerName, pwchInstanceName)#uselib "odbcbcp.dll"
#func global SQLInitEnumServers "SQLInitEnumServers" sptr, sptr
; SQLInitEnumServers pwchServerName, pwchInstanceName ; 戻り値は stat
; pwchServerName : LPWSTR -> "sptr"
; pwchInstanceName : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "odbcbcp.dll"
#cfunc global SQLInitEnumServers "SQLInitEnumServers" wstr, wstr
; res = SQLInitEnumServers(pwchServerName, pwchInstanceName)
; pwchServerName : LPWSTR -> "wstr"
; pwchInstanceName : LPWSTR -> "wstr"; HANDLE SQLInitEnumServers(LPWSTR pwchServerName, LPWSTR pwchInstanceName)
#uselib "odbcbcp.dll"
#cfunc global SQLInitEnumServers "SQLInitEnumServers" wstr, wstr
; res = SQLInitEnumServers(pwchServerName, pwchInstanceName)
; pwchServerName : LPWSTR -> "wstr"
; pwchInstanceName : LPWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbcbcp = windows.NewLazySystemDLL("odbcbcp.dll")
procSQLInitEnumServers = odbcbcp.NewProc("SQLInitEnumServers")
)
// pwchServerName (LPWSTR), pwchInstanceName (LPWSTR)
r1, _, err := procSQLInitEnumServers.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwchServerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwchInstanceName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction SQLInitEnumServers(
pwchServerName: PWideChar; // LPWSTR
pwchInstanceName: PWideChar // LPWSTR
): THandle; stdcall;
external 'odbcbcp.dll' name 'SQLInitEnumServers';result := DllCall("odbcbcp\SQLInitEnumServers"
, "WStr", pwchServerName ; LPWSTR
, "WStr", pwchInstanceName ; LPWSTR
, "Ptr") ; return: HANDLE●SQLInitEnumServers(pwchServerName, pwchInstanceName) = DLL("odbcbcp.dll", "void* SQLInitEnumServers(char*, char*)")
# 呼び出し: SQLInitEnumServers(pwchServerName, pwchInstanceName)
# pwchServerName : LPWSTR -> "char*"
# pwchInstanceName : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。