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

SQLAllocHandleStd

関数
標準準拠の方式でODBCハンドルを割り当てる。
DLLODBC32.dll呼出規約winapi

シグネチャ

// ODBC32.dll
#include <windows.h>

SHORT SQLAllocHandleStd(
    SHORT fHandleType,
    void* hInput,
    void** phOutput
);

パラメーター

名前方向
fHandleTypeSHORTin
hInputvoid*inout
phOutputvoid**out

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll
#include <windows.h>

SHORT SQLAllocHandleStd(
    SHORT fHandleType,
    void* hInput,
    void** phOutput
);
[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLAllocHandleStd(
    short fHandleType,   // SHORT
    IntPtr hInput,   // void* in/out
    IntPtr phOutput   // void** out
);
<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLAllocHandleStd(
    fHandleType As Short,   ' SHORT
    hInput As IntPtr,   ' void* in/out
    phOutput As IntPtr   ' void** out
) As Short
End Function
' fHandleType : SHORT
' hInput : void* in/out
' phOutput : void** out
Declare PtrSafe Function SQLAllocHandleStd Lib "odbc32" ( _
    ByVal fHandleType As Integer, _
    ByVal hInput As LongPtr, _
    ByVal phOutput As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLAllocHandleStd = ctypes.windll.odbc32.SQLAllocHandleStd
SQLAllocHandleStd.restype = ctypes.c_short
SQLAllocHandleStd.argtypes = [
    ctypes.c_short,  # fHandleType : SHORT
    ctypes.POINTER(None),  # hInput : void* in/out
    ctypes.c_void_p,  # phOutput : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLAllocHandleStd = Fiddle::Function.new(
  lib['SQLAllocHandleStd'],
  [
    Fiddle::TYPE_SHORT,  # fHandleType : SHORT
    Fiddle::TYPE_VOIDP,  # hInput : void* in/out
    Fiddle::TYPE_VOIDP,  # phOutput : void** out
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLAllocHandleStd(
        fHandleType: i16,  // SHORT
        hInput: *mut (),  // void* in/out
        phOutput: *mut *mut ()  // void** out
    ) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLAllocHandleStd(short fHandleType, IntPtr hInput, IntPtr phOutput);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLAllocHandleStd' -Namespace Win32 -PassThru
# $api::SQLAllocHandleStd(fHandleType, hInput, phOutput)
#uselib "ODBC32.dll"
#func global SQLAllocHandleStd "SQLAllocHandleStd" sptr, sptr, sptr
; SQLAllocHandleStd fHandleType, hInput, phOutput   ; 戻り値は stat
; fHandleType : SHORT -> "sptr"
; hInput : void* in/out -> "sptr"
; phOutput : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ODBC32.dll"
#cfunc global SQLAllocHandleStd "SQLAllocHandleStd" int, sptr, sptr
; res = SQLAllocHandleStd(fHandleType, hInput, phOutput)
; fHandleType : SHORT -> "int"
; hInput : void* in/out -> "sptr"
; phOutput : void** out -> "sptr"
; SHORT SQLAllocHandleStd(SHORT fHandleType, void* hInput, void** phOutput)
#uselib "ODBC32.dll"
#cfunc global SQLAllocHandleStd "SQLAllocHandleStd" int, intptr, intptr
; res = SQLAllocHandleStd(fHandleType, hInput, phOutput)
; fHandleType : SHORT -> "int"
; hInput : void* in/out -> "intptr"
; phOutput : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLAllocHandleStd = odbc32.NewProc("SQLAllocHandleStd")
)

// fHandleType (SHORT), hInput (void* in/out), phOutput (void** out)
r1, _, err := procSQLAllocHandleStd.Call(
	uintptr(fHandleType),
	uintptr(hInput),
	uintptr(phOutput),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLAllocHandleStd(
  fHandleType: Smallint;   // SHORT
  hInput: Pointer;   // void* in/out
  phOutput: Pointer   // void** out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLAllocHandleStd';
result := DllCall("ODBC32\SQLAllocHandleStd"
    , "Short", fHandleType   ; SHORT
    , "Ptr", hInput   ; void* in/out
    , "Ptr", phOutput   ; void** out
    , "Short")   ; return: SHORT
●SQLAllocHandleStd(fHandleType, hInput, phOutput) = DLL("ODBC32.dll", "int SQLAllocHandleStd(int, void*, void*)")
# 呼び出し: SQLAllocHandleStd(fHandleType, hInput, phOutput)
# fHandleType : SHORT -> "int"
# hInput : void* in/out -> "void*"
# phOutput : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。