Win32 API 日本語リファレンス
ホームStorage.Jet › JetBeginSessionA

JetBeginSessionA

関数
ESEデータベースへのセッションを開始する(ANSI版)。
DLLESENT.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ESENT.dll  (ANSI / -A)
#include <windows.h>

INT JetBeginSessionA(
    JET_INSTANCE instance,
    JET_SESID* psesid,
    CHAR* szUserName,   // optional
    CHAR* szPassword   // optional
);

パラメーター

名前方向
instanceJET_INSTANCEin
psesidJET_SESID*out
szUserNameCHAR*inoptional
szPasswordCHAR*inoptional

戻り値の型: INT

各言語での呼び出し定義

// ESENT.dll  (ANSI / -A)
#include <windows.h>

INT JetBeginSessionA(
    JET_INSTANCE instance,
    JET_SESID* psesid,
    CHAR* szUserName,   // optional
    CHAR* szPassword   // optional
);
[DllImport("ESENT.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int JetBeginSessionA(
    UIntPtr instance,   // JET_INSTANCE
    out UIntPtr psesid,   // JET_SESID* out
    IntPtr szUserName,   // CHAR* optional
    IntPtr szPassword   // CHAR* optional
);
<DllImport("ESENT.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function JetBeginSessionA(
    instance As UIntPtr,   ' JET_INSTANCE
    <Out> ByRef psesid As UIntPtr,   ' JET_SESID* out
    szUserName As IntPtr,   ' CHAR* optional
    szPassword As IntPtr   ' CHAR* optional
) As Integer
End Function
' instance : JET_INSTANCE
' psesid : JET_SESID* out
' szUserName : CHAR* optional
' szPassword : CHAR* optional
Declare PtrSafe Function JetBeginSessionA Lib "esent" ( _
    ByVal instance As LongPtr, _
    ByRef psesid As LongPtr, _
    ByVal szUserName As LongPtr, _
    ByVal szPassword As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

JetBeginSessionA = ctypes.windll.esent.JetBeginSessionA
JetBeginSessionA.restype = ctypes.c_int
JetBeginSessionA.argtypes = [
    ctypes.c_size_t,  # instance : JET_INSTANCE
    ctypes.c_void_p,  # psesid : JET_SESID* out
    ctypes.POINTER(ctypes.c_byte),  # szUserName : CHAR* optional
    ctypes.POINTER(ctypes.c_byte),  # szPassword : CHAR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ESENT.dll')
JetBeginSessionA = Fiddle::Function.new(
  lib['JetBeginSessionA'],
  [
    Fiddle::TYPE_UINTPTR_T,  # instance : JET_INSTANCE
    Fiddle::TYPE_VOIDP,  # psesid : JET_SESID* out
    Fiddle::TYPE_VOIDP,  # szUserName : CHAR* optional
    Fiddle::TYPE_VOIDP,  # szPassword : CHAR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "esent")]
extern "system" {
    fn JetBeginSessionA(
        instance: usize,  // JET_INSTANCE
        psesid: *mut usize,  // JET_SESID* out
        szUserName: *mut i8,  // CHAR* optional
        szPassword: *mut i8  // CHAR* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ESENT.dll", CharSet = CharSet.Ansi)]
public static extern int JetBeginSessionA(UIntPtr instance, out UIntPtr psesid, IntPtr szUserName, IntPtr szPassword);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ESENT_JetBeginSessionA' -Namespace Win32 -PassThru
# $api::JetBeginSessionA(instance, psesid, szUserName, szPassword)
#uselib "ESENT.dll"
#func global JetBeginSessionA "JetBeginSessionA" sptr, sptr, sptr, sptr
; JetBeginSessionA instance, psesid, varptr(szUserName), varptr(szPassword)   ; 戻り値は stat
; instance : JET_INSTANCE -> "sptr"
; psesid : JET_SESID* out -> "sptr"
; szUserName : CHAR* optional -> "sptr"
; szPassword : CHAR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ESENT.dll"
#cfunc global JetBeginSessionA "JetBeginSessionA" sptr, int, var, var
; res = JetBeginSessionA(instance, psesid, szUserName, szPassword)
; instance : JET_INSTANCE -> "sptr"
; psesid : JET_SESID* out -> "int"
; szUserName : CHAR* optional -> "var"
; szPassword : CHAR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT JetBeginSessionA(JET_INSTANCE instance, JET_SESID* psesid, CHAR* szUserName, CHAR* szPassword)
#uselib "ESENT.dll"
#cfunc global JetBeginSessionA "JetBeginSessionA" intptr, int, var, var
; res = JetBeginSessionA(instance, psesid, szUserName, szPassword)
; instance : JET_INSTANCE -> "intptr"
; psesid : JET_SESID* out -> "int"
; szUserName : CHAR* optional -> "var"
; szPassword : CHAR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	esent = windows.NewLazySystemDLL("ESENT.dll")
	procJetBeginSessionA = esent.NewProc("JetBeginSessionA")
)

// instance (JET_INSTANCE), psesid (JET_SESID* out), szUserName (CHAR* optional), szPassword (CHAR* optional)
r1, _, err := procJetBeginSessionA.Call(
	uintptr(instance),
	uintptr(psesid),
	uintptr(szUserName),
	uintptr(szPassword),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function JetBeginSessionA(
  instance: NativeUInt;   // JET_INSTANCE
  psesid: Pointer;   // JET_SESID* out
  szUserName: Pointer;   // CHAR* optional
  szPassword: Pointer   // CHAR* optional
): Integer; stdcall;
  external 'ESENT.dll' name 'JetBeginSessionA';
result := DllCall("ESENT\JetBeginSessionA"
    , "UPtr", instance   ; JET_INSTANCE
    , "Ptr", psesid   ; JET_SESID* out
    , "Ptr", szUserName   ; CHAR* optional
    , "Ptr", szPassword   ; CHAR* optional
    , "Int")   ; return: INT
●JetBeginSessionA(instance, psesid, szUserName, szPassword) = DLL("ESENT.dll", "int JetBeginSessionA(int, void*, void*, void*)")
# 呼び出し: JetBeginSessionA(instance, psesid, szUserName, szPassword)
# instance : JET_INSTANCE -> "int"
# psesid : JET_SESID* out -> "void*"
# szUserName : CHAR* optional -> "void*"
# szPassword : CHAR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。