ホーム › Storage.Jet › JetBeginSessionA
JetBeginSessionA
関数ESEデータベースへのセッションを開始する(ANSI版)。
シグネチャ
// ESENT.dll (ANSI / -A)
#include <windows.h>
INT JetBeginSessionA(
JET_INSTANCE instance,
JET_SESID* psesid,
CHAR* szUserName, // optional
CHAR* szPassword // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| instance | JET_INSTANCE | in | セッションを開始する対象のインスタンスハンドル。 |
| psesid | JET_SESID* | out | 生成されたセッションIDを受け取るJET_SESIDポインタ。 |
| szUserName | CHAR* | inoptional | 認証に用いるユーザー名を指すANSI文字列。未使用のためNULL可。 |
| szPassword | CHAR* | inoptional | 認証に用いるパスワードを指すANSI文字列。未使用のためNULL可。 |
戻り値の型: 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, varptr(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, var, var, var ; res = JetBeginSessionA(instance, psesid, szUserName, szPassword) ; instance : JET_INSTANCE -> "sptr" ; psesid : JET_SESID* out -> "var" ; szUserName : CHAR* optional -> "var" ; szPassword : CHAR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ESENT.dll" #cfunc global JetBeginSessionA "JetBeginSessionA" sptr, sptr, sptr, sptr ; res = JetBeginSessionA(instance, varptr(psesid), varptr(szUserName), varptr(szPassword)) ; instance : JET_INSTANCE -> "sptr" ; psesid : JET_SESID* out -> "sptr" ; szUserName : CHAR* optional -> "sptr" ; szPassword : CHAR* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT JetBeginSessionA(JET_INSTANCE instance, JET_SESID* psesid, CHAR* szUserName, CHAR* szPassword) #uselib "ESENT.dll" #cfunc global JetBeginSessionA "JetBeginSessionA" intptr, var, var, var ; res = JetBeginSessionA(instance, psesid, szUserName, szPassword) ; instance : JET_INSTANCE -> "intptr" ; psesid : JET_SESID* out -> "var" ; 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, intptr, intptr, intptr ; res = JetBeginSessionA(instance, varptr(psesid), varptr(szUserName), varptr(szPassword)) ; instance : JET_INSTANCE -> "intptr" ; psesid : JET_SESID* out -> "intptr" ; szUserName : CHAR* optional -> "intptr" ; szPassword : CHAR* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // INTfunction 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)。const std = @import("std");
extern "esent" fn JetBeginSessionA(
instance: usize, // JET_INSTANCE
psesid: [*c]usize, // JET_SESID* out
szUserName: [*c]i8, // CHAR* optional
szPassword: [*c]i8 // CHAR* optional
) callconv(std.os.windows.WINAPI) i32;proc JetBeginSessionA(
instance: uint, # JET_INSTANCE
psesid: ptr uint, # JET_SESID* out
szUserName: ptr int8, # CHAR* optional
szPassword: ptr int8 # CHAR* optional
): int32 {.importc: "JetBeginSessionA", stdcall, dynlib: "ESENT.dll".}pragma(lib, "esent");
extern(Windows)
int JetBeginSessionA(
size_t instance, // JET_INSTANCE
size_t* psesid, // JET_SESID* out
byte* szUserName, // CHAR* optional
byte* szPassword // CHAR* optional
);ccall((:JetBeginSessionA, "ESENT.dll"), stdcall, Int32,
(Csize_t, Ptr{Csize_t}, Ptr{Int8}, Ptr{Int8}),
instance, psesid, szUserName, szPassword)
# instance : JET_INSTANCE -> Csize_t
# psesid : JET_SESID* out -> Ptr{Csize_t}
# szUserName : CHAR* optional -> Ptr{Int8}
# szPassword : CHAR* optional -> Ptr{Int8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t JetBeginSessionA(
uintptr_t instance,
uintptr_t* psesid,
int8_t* szUserName,
int8_t* szPassword);
]]
local esent = ffi.load("esent")
-- esent.JetBeginSessionA(instance, psesid, szUserName, szPassword)
-- instance : JET_INSTANCE
-- psesid : JET_SESID* out
-- szUserName : CHAR* optional
-- szPassword : CHAR* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ESENT.dll');
const JetBeginSessionA = lib.func('__stdcall', 'JetBeginSessionA', 'int32_t', ['uintptr_t', 'uintptr_t *', 'int8_t *', 'int8_t *']);
// JetBeginSessionA(instance, psesid, szUserName, szPassword)
// instance : JET_INSTANCE -> 'uintptr_t'
// psesid : JET_SESID* out -> 'uintptr_t *'
// szUserName : CHAR* optional -> 'int8_t *'
// szPassword : CHAR* optional -> 'int8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ESENT.dll", {
JetBeginSessionA: { parameters: ["usize", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.JetBeginSessionA(instance, psesid, szUserName, szPassword)
// instance : JET_INSTANCE -> "usize"
// psesid : JET_SESID* out -> "pointer"
// szUserName : CHAR* optional -> "pointer"
// szPassword : CHAR* optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t JetBeginSessionA(
size_t instance,
size_t* psesid,
int8_t* szUserName,
int8_t* szPassword);
C, "ESENT.dll");
// $ffi->JetBeginSessionA(instance, psesid, szUserName, szPassword);
// instance : JET_INSTANCE
// psesid : JET_SESID* out
// szUserName : CHAR* optional
// szPassword : CHAR* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Esent extends StdCallLibrary {
Esent INSTANCE = Native.load("esent", Esent.class, W32APIOptions.ASCII_OPTIONS);
int JetBeginSessionA(
long instance, // JET_INSTANCE
LongByReference psesid, // JET_SESID* out
byte[] szUserName, // CHAR* optional
byte[] szPassword // CHAR* optional
);
}@[Link("esent")]
lib LibESENT
fun JetBeginSessionA = JetBeginSessionA(
instance : LibC::SizeT, # JET_INSTANCE
psesid : LibC::SizeT*, # JET_SESID* out
szUserName : Int8*, # CHAR* optional
szPassword : Int8* # CHAR* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef JetBeginSessionANative = Int32 Function(UintPtr, Pointer<UintPtr>, Pointer<Int8>, Pointer<Int8>);
typedef JetBeginSessionADart = int Function(int, Pointer<UintPtr>, Pointer<Int8>, Pointer<Int8>);
final JetBeginSessionA = DynamicLibrary.open('ESENT.dll')
.lookupFunction<JetBeginSessionANative, JetBeginSessionADart>('JetBeginSessionA');
// instance : JET_INSTANCE -> UintPtr
// psesid : JET_SESID* out -> Pointer<UintPtr>
// szUserName : CHAR* optional -> Pointer<Int8>
// szPassword : CHAR* optional -> Pointer<Int8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "JetBeginSessionA"
c_JetBeginSessionA :: CUIntPtr -> Ptr CUIntPtr -> Ptr Int8 -> Ptr Int8 -> IO Int32
-- instance : JET_INSTANCE -> CUIntPtr
-- psesid : JET_SESID* out -> Ptr CUIntPtr
-- szUserName : CHAR* optional -> Ptr Int8
-- szPassword : CHAR* optional -> Ptr Int8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let jetbeginsessiona =
foreign "JetBeginSessionA"
(size_t @-> (ptr size_t) @-> (ptr int8_t) @-> (ptr int8_t) @-> returning int32_t)
(* instance : JET_INSTANCE -> size_t *)
(* psesid : JET_SESID* out -> (ptr size_t) *)
(* szUserName : CHAR* optional -> (ptr int8_t) *)
(* szPassword : CHAR* optional -> (ptr int8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library esent (t "ESENT.dll"))
(cffi:use-foreign-library esent)
(cffi:defcfun ("JetBeginSessionA" jet-begin-session-a :convention :stdcall) :int32
(instance :uint64) ; JET_INSTANCE
(psesid :pointer) ; JET_SESID* out
(sz-user-name :pointer) ; CHAR* optional
(sz-password :pointer)) ; CHAR* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $JetBeginSessionA = Win32::API::More->new('ESENT',
'int JetBeginSessionA(WPARAM instance, LPVOID psesid, LPVOID szUserName, LPVOID szPassword)');
# my $ret = $JetBeginSessionA->Call($instance, $psesid, $szUserName, $szPassword);
# instance : JET_INSTANCE -> WPARAM
# psesid : JET_SESID* out -> LPVOID
# szUserName : CHAR* optional -> LPVOID
# szPassword : CHAR* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f JetBeginSessionW (Unicode版) — ESEデータベースへのセッションを開始する。