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