ホーム › System.Search › bcp_initW
bcp_initW
関数一括コピー操作をUnicode文字列で初期化する。
シグネチャ
// odbcbcp.dll (Unicode / -W)
#include <windows.h>
SHORT bcp_initW(
void* param0,
LPCWSTR param1,
LPCWSTR param2,
LPCWSTR param3,
INT param4
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| param0 | void* | inout | BCP操作のODBC接続ハンドル。 |
| param1 | LPCWSTR | in | コピー対象のテーブルまたはビュー名。Unicode文字列。 |
| param2 | LPCWSTR | in | データファイル名。Unicode文字列。メモリ転送時はNULL可。 |
| param3 | LPCWSTR | in | エラーファイル名。Unicode文字列。不要ならNULL可。 |
| param4 | INT | in | 転送方向。DB_IN(ファイル→DB)かDB_OUT(DB→ファイル)を指定する。 |
戻り値の型: SHORT
各言語での呼び出し定義
// odbcbcp.dll (Unicode / -W)
#include <windows.h>
SHORT bcp_initW(
void* param0,
LPCWSTR param1,
LPCWSTR param2,
LPCWSTR param3,
INT param4
);[DllImport("odbcbcp.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short bcp_initW(
IntPtr param0, // void* in/out
[MarshalAs(UnmanagedType.LPWStr)] string param1, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string param2, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string param3, // LPCWSTR
int param4 // INT
);<DllImport("odbcbcp.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function bcp_initW(
param0 As IntPtr, ' void* in/out
<MarshalAs(UnmanagedType.LPWStr)> param1 As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> param2 As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> param3 As String, ' LPCWSTR
param4 As Integer ' INT
) As Short
End Function' param0 : void* in/out
' param1 : LPCWSTR
' param2 : LPCWSTR
' param3 : LPCWSTR
' param4 : INT
Declare PtrSafe Function bcp_initW Lib "odbcbcp" ( _
ByVal param0 As LongPtr, _
ByVal param1 As LongPtr, _
ByVal param2 As LongPtr, _
ByVal param3 As LongPtr, _
ByVal param4 As Long) As Integer
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
bcp_initW = ctypes.windll.odbcbcp.bcp_initW
bcp_initW.restype = ctypes.c_short
bcp_initW.argtypes = [
ctypes.POINTER(None), # param0 : void* in/out
wintypes.LPCWSTR, # param1 : LPCWSTR
wintypes.LPCWSTR, # param2 : LPCWSTR
wintypes.LPCWSTR, # param3 : LPCWSTR
ctypes.c_int, # param4 : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('odbcbcp.dll')
bcp_initW = Fiddle::Function.new(
lib['bcp_initW'],
[
Fiddle::TYPE_VOIDP, # param0 : void* in/out
Fiddle::TYPE_VOIDP, # param1 : LPCWSTR
Fiddle::TYPE_VOIDP, # param2 : LPCWSTR
Fiddle::TYPE_VOIDP, # param3 : LPCWSTR
Fiddle::TYPE_INT, # param4 : INT
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbcbcp")]
extern "system" {
fn bcp_initW(
param0: *mut (), // void* in/out
param1: *const u16, // LPCWSTR
param2: *const u16, // LPCWSTR
param3: *const u16, // LPCWSTR
param4: i32 // INT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("odbcbcp.dll", CharSet = CharSet.Unicode)]
public static extern short bcp_initW(IntPtr param0, [MarshalAs(UnmanagedType.LPWStr)] string param1, [MarshalAs(UnmanagedType.LPWStr)] string param2, [MarshalAs(UnmanagedType.LPWStr)] string param3, int param4);
"@
$api = Add-Type -MemberDefinition $sig -Name 'odbcbcp_bcp_initW' -Namespace Win32 -PassThru
# $api::bcp_initW(param0, param1, param2, param3, param4)#uselib "odbcbcp.dll"
#func global bcp_initW "bcp_initW" wptr, wptr, wptr, wptr, wptr
; bcp_initW param0, param1, param2, param3, param4 ; 戻り値は stat
; param0 : void* in/out -> "wptr"
; param1 : LPCWSTR -> "wptr"
; param2 : LPCWSTR -> "wptr"
; param3 : LPCWSTR -> "wptr"
; param4 : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "odbcbcp.dll"
#cfunc global bcp_initW "bcp_initW" sptr, wstr, wstr, wstr, int
; res = bcp_initW(param0, param1, param2, param3, param4)
; param0 : void* in/out -> "sptr"
; param1 : LPCWSTR -> "wstr"
; param2 : LPCWSTR -> "wstr"
; param3 : LPCWSTR -> "wstr"
; param4 : INT -> "int"; SHORT bcp_initW(void* param0, LPCWSTR param1, LPCWSTR param2, LPCWSTR param3, INT param4)
#uselib "odbcbcp.dll"
#cfunc global bcp_initW "bcp_initW" intptr, wstr, wstr, wstr, int
; res = bcp_initW(param0, param1, param2, param3, param4)
; param0 : void* in/out -> "intptr"
; param1 : LPCWSTR -> "wstr"
; param2 : LPCWSTR -> "wstr"
; param3 : LPCWSTR -> "wstr"
; param4 : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbcbcp = windows.NewLazySystemDLL("odbcbcp.dll")
procbcp_initW = odbcbcp.NewProc("bcp_initW")
)
// param0 (void* in/out), param1 (LPCWSTR), param2 (LPCWSTR), param3 (LPCWSTR), param4 (INT)
r1, _, err := procbcp_initW.Call(
uintptr(param0),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(param1))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(param2))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(param3))),
uintptr(param4),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction bcp_initW(
param0: Pointer; // void* in/out
param1: PWideChar; // LPCWSTR
param2: PWideChar; // LPCWSTR
param3: PWideChar; // LPCWSTR
param4: Integer // INT
): Smallint; stdcall;
external 'odbcbcp.dll' name 'bcp_initW';result := DllCall("odbcbcp\bcp_initW"
, "Ptr", param0 ; void* in/out
, "WStr", param1 ; LPCWSTR
, "WStr", param2 ; LPCWSTR
, "WStr", param3 ; LPCWSTR
, "Int", param4 ; INT
, "Short") ; return: SHORT●bcp_initW(param0, param1, param2, param3, param4) = DLL("odbcbcp.dll", "int bcp_initW(void*, char*, char*, char*, int)")
# 呼び出し: bcp_initW(param0, param1, param2, param3, param4)
# param0 : void* in/out -> "void*"
# param1 : LPCWSTR -> "char*"
# param2 : LPCWSTR -> "char*"
# param3 : LPCWSTR -> "char*"
# param4 : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "odbcbcp" fn bcp_initW(
param0: ?*anyopaque, // void* in/out
param1: [*c]const u16, // LPCWSTR
param2: [*c]const u16, // LPCWSTR
param3: [*c]const u16, // LPCWSTR
param4: i32 // INT
) callconv(std.os.windows.WINAPI) i16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc bcp_initW(
param0: pointer, # void* in/out
param1: WideCString, # LPCWSTR
param2: WideCString, # LPCWSTR
param3: WideCString, # LPCWSTR
param4: int32 # INT
): int16 {.importc: "bcp_initW", stdcall, dynlib: "odbcbcp.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "odbcbcp");
extern(Windows)
short bcp_initW(
void* param0, // void* in/out
const(wchar)* param1, // LPCWSTR
const(wchar)* param2, // LPCWSTR
const(wchar)* param3, // LPCWSTR
int param4 // INT
);ccall((:bcp_initW, "odbcbcp.dll"), stdcall, Int16,
(Ptr{Cvoid}, Cwstring, Cwstring, Cwstring, Int32),
param0, param1, param2, param3, param4)
# param0 : void* in/out -> Ptr{Cvoid}
# param1 : LPCWSTR -> Cwstring
# param2 : LPCWSTR -> Cwstring
# param3 : LPCWSTR -> Cwstring
# param4 : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int16_t bcp_initW(
void* param0,
const uint16_t* param1,
const uint16_t* param2,
const uint16_t* param3,
int32_t param4);
]]
local odbcbcp = ffi.load("odbcbcp")
-- odbcbcp.bcp_initW(param0, param1, param2, param3, param4)
-- param0 : void* in/out
-- param1 : LPCWSTR
-- param2 : LPCWSTR
-- param3 : LPCWSTR
-- param4 : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('odbcbcp.dll');
const bcp_initW = lib.func('__stdcall', 'bcp_initW', 'int16_t', ['void *', 'str16', 'str16', 'str16', 'int32_t']);
// bcp_initW(param0, param1, param2, param3, param4)
// param0 : void* in/out -> 'void *'
// param1 : LPCWSTR -> 'str16'
// param2 : LPCWSTR -> 'str16'
// param3 : LPCWSTR -> 'str16'
// param4 : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("odbcbcp.dll", {
bcp_initW: { parameters: ["pointer", "buffer", "buffer", "buffer", "i32"], result: "i16" },
});
// lib.symbols.bcp_initW(param0, param1, param2, param3, param4)
// param0 : void* in/out -> "pointer"
// param1 : LPCWSTR -> "buffer"
// param2 : LPCWSTR -> "buffer"
// param3 : LPCWSTR -> "buffer"
// param4 : INT -> "i32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t bcp_initW(
void* param0,
const uint16_t* param1,
const uint16_t* param2,
const uint16_t* param3,
int32_t param4);
C, "odbcbcp.dll");
// $ffi->bcp_initW(param0, param1, param2, param3, param4);
// param0 : void* in/out
// param1 : LPCWSTR
// param2 : LPCWSTR
// param3 : LPCWSTR
// param4 : INT
// 構造体/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 Odbcbcp extends StdCallLibrary {
Odbcbcp INSTANCE = Native.load("odbcbcp", Odbcbcp.class, W32APIOptions.UNICODE_OPTIONS);
short bcp_initW(
Pointer param0, // void* in/out
WString param1, // LPCWSTR
WString param2, // LPCWSTR
WString param3, // LPCWSTR
int param4 // INT
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("odbcbcp")]
lib Libodbcbcp
fun bcp_initW = bcp_initW(
param0 : Void*, # void* in/out
param1 : UInt16*, # LPCWSTR
param2 : UInt16*, # LPCWSTR
param3 : UInt16*, # LPCWSTR
param4 : Int32 # INT
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef bcp_initWNative = Int16 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Int32);
typedef bcp_initWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int);
final bcp_initW = DynamicLibrary.open('odbcbcp.dll')
.lookupFunction<bcp_initWNative, bcp_initWDart>('bcp_initW');
// param0 : void* in/out -> Pointer<Void>
// param1 : LPCWSTR -> Pointer<Utf16>
// param2 : LPCWSTR -> Pointer<Utf16>
// param3 : LPCWSTR -> Pointer<Utf16>
// param4 : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function bcp_initW(
param0: Pointer; // void* in/out
param1: PWideChar; // LPCWSTR
param2: PWideChar; // LPCWSTR
param3: PWideChar; // LPCWSTR
param4: Integer // INT
): Smallint; stdcall;
external 'odbcbcp.dll' name 'bcp_initW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "bcp_initW"
c_bcp_initW :: Ptr () -> CWString -> CWString -> CWString -> Int32 -> IO Int16
-- param0 : void* in/out -> Ptr ()
-- param1 : LPCWSTR -> CWString
-- param2 : LPCWSTR -> CWString
-- param3 : LPCWSTR -> CWString
-- param4 : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bcp_initw =
foreign "bcp_initW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> returning int16_t)
(* param0 : void* in/out -> (ptr void) *)
(* param1 : LPCWSTR -> (ptr uint16_t) *)
(* param2 : LPCWSTR -> (ptr uint16_t) *)
(* param3 : LPCWSTR -> (ptr uint16_t) *)
(* param4 : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbcbcp (t "odbcbcp.dll"))
(cffi:use-foreign-library odbcbcp)
(cffi:defcfun ("bcp_initW" bcp-init-w :convention :stdcall) :int16
(param0 :pointer) ; void* in/out
(param1 (:string :encoding :utf-16le)) ; LPCWSTR
(param2 (:string :encoding :utf-16le)) ; LPCWSTR
(param3 (:string :encoding :utf-16le)) ; LPCWSTR
(param4 :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $bcp_initW = Win32::API::More->new('odbcbcp',
'short bcp_initW(LPVOID param0, LPCWSTR param1, LPCWSTR param2, LPCWSTR param3, int param4)');
# my $ret = $bcp_initW->Call($param0, $param1, $param2, $param3, $param4);
# param0 : void* in/out -> LPVOID
# param1 : LPCWSTR -> LPCWSTR
# param2 : LPCWSTR -> LPCWSTR
# param3 : LPCWSTR -> LPCWSTR
# param4 : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f bcp_initA (ANSI版) — 一括コピー操作をANSI文字列で初期化する。