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

SQLAllocEnv

関数
ODBC環境ハンドルを割り当てる(旧式)。
DLLODBC32.dll呼出規約winapi

シグネチャ

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

SHORT SQLAllocEnv(
    void** EnvironmentHandle
);

パラメーター

名前方向
EnvironmentHandlevoid**out

戻り値の型: SHORT

各言語での呼び出し定義

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

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

SQLAllocEnv = ctypes.windll.odbc32.SQLAllocEnv
SQLAllocEnv.restype = ctypes.c_short
SQLAllocEnv.argtypes = [
    ctypes.c_void_p,  # EnvironmentHandle : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLAllocEnv = odbc32.NewProc("SQLAllocEnv")
)

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