ホーム › Security.Cryptography › ImportInformationCard
ImportInformationCard
関数指定ファイルから情報カードをインポートする。
シグネチャ
// infocardapi.dll
#include <windows.h>
HRESULT ImportInformationCard(
LPCWSTR fileName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| fileName | LPCWSTR | in | インポートするインフォメーションカード(.crds)ファイルのパス文字列。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// infocardapi.dll
#include <windows.h>
HRESULT ImportInformationCard(
LPCWSTR fileName
);[DllImport("infocardapi.dll", ExactSpelling = true)]
static extern int ImportInformationCard(
[MarshalAs(UnmanagedType.LPWStr)] string fileName // LPCWSTR
);<DllImport("infocardapi.dll", ExactSpelling:=True)>
Public Shared Function ImportInformationCard(
<MarshalAs(UnmanagedType.LPWStr)> fileName As String ' LPCWSTR
) As Integer
End Function' fileName : LPCWSTR
Declare PtrSafe Function ImportInformationCard Lib "infocardapi" ( _
ByVal fileName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ImportInformationCard = ctypes.windll.infocardapi.ImportInformationCard
ImportInformationCard.restype = ctypes.c_int
ImportInformationCard.argtypes = [
wintypes.LPCWSTR, # fileName : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('infocardapi.dll')
ImportInformationCard = Fiddle::Function.new(
lib['ImportInformationCard'],
[
Fiddle::TYPE_VOIDP, # fileName : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "infocardapi")]
extern "system" {
fn ImportInformationCard(
fileName: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("infocardapi.dll")]
public static extern int ImportInformationCard([MarshalAs(UnmanagedType.LPWStr)] string fileName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'infocardapi_ImportInformationCard' -Namespace Win32 -PassThru
# $api::ImportInformationCard(fileName)#uselib "infocardapi.dll"
#func global ImportInformationCard "ImportInformationCard" sptr
; ImportInformationCard fileName ; 戻り値は stat
; fileName : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "infocardapi.dll"
#cfunc global ImportInformationCard "ImportInformationCard" wstr
; res = ImportInformationCard(fileName)
; fileName : LPCWSTR -> "wstr"; HRESULT ImportInformationCard(LPCWSTR fileName)
#uselib "infocardapi.dll"
#cfunc global ImportInformationCard "ImportInformationCard" wstr
; res = ImportInformationCard(fileName)
; fileName : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
infocardapi = windows.NewLazySystemDLL("infocardapi.dll")
procImportInformationCard = infocardapi.NewProc("ImportInformationCard")
)
// fileName (LPCWSTR)
r1, _, err := procImportInformationCard.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(fileName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ImportInformationCard(
fileName: PWideChar // LPCWSTR
): Integer; stdcall;
external 'infocardapi.dll' name 'ImportInformationCard';result := DllCall("infocardapi\ImportInformationCard"
, "WStr", fileName ; LPCWSTR
, "Int") ; return: HRESULT●ImportInformationCard(fileName) = DLL("infocardapi.dll", "int ImportInformationCard(char*)")
# 呼び出し: ImportInformationCard(fileName)
# fileName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "infocardapi" fn ImportInformationCard(
fileName: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc ImportInformationCard(
fileName: WideCString # LPCWSTR
): int32 {.importc: "ImportInformationCard", stdcall, dynlib: "infocardapi.dll".}pragma(lib, "infocardapi");
extern(Windows)
int ImportInformationCard(
const(wchar)* fileName // LPCWSTR
);ccall((:ImportInformationCard, "infocardapi.dll"), stdcall, Int32,
(Cwstring,),
fileName)
# fileName : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ImportInformationCard(
const uint16_t* fileName);
]]
local infocardapi = ffi.load("infocardapi")
-- infocardapi.ImportInformationCard(fileName)
-- fileName : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('infocardapi.dll');
const ImportInformationCard = lib.func('__stdcall', 'ImportInformationCard', 'int32_t', ['str16']);
// ImportInformationCard(fileName)
// fileName : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("infocardapi.dll", {
ImportInformationCard: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.ImportInformationCard(fileName)
// fileName : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ImportInformationCard(
const uint16_t* fileName);
C, "infocardapi.dll");
// $ffi->ImportInformationCard(fileName);
// fileName : LPCWSTR
// 構造体/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 Infocardapi extends StdCallLibrary {
Infocardapi INSTANCE = Native.load("infocardapi", Infocardapi.class);
int ImportInformationCard(
WString fileName // LPCWSTR
);
}@[Link("infocardapi")]
lib Libinfocardapi
fun ImportInformationCard = ImportInformationCard(
fileName : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ImportInformationCardNative = Int32 Function(Pointer<Utf16>);
typedef ImportInformationCardDart = int Function(Pointer<Utf16>);
final ImportInformationCard = DynamicLibrary.open('infocardapi.dll')
.lookupFunction<ImportInformationCardNative, ImportInformationCardDart>('ImportInformationCard');
// fileName : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ImportInformationCard(
fileName: PWideChar // LPCWSTR
): Integer; stdcall;
external 'infocardapi.dll' name 'ImportInformationCard';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ImportInformationCard"
c_ImportInformationCard :: CWString -> IO Int32
-- fileName : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let importinformationcard =
foreign "ImportInformationCard"
((ptr uint16_t) @-> returning int32_t)
(* fileName : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library infocardapi (t "infocardapi.dll"))
(cffi:use-foreign-library infocardapi)
(cffi:defcfun ("ImportInformationCard" import-information-card :convention :stdcall) :int32
(file-name (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ImportInformationCard = Win32::API::More->new('infocardapi',
'int ImportInformationCard(LPCWSTR fileName)');
# my $ret = $ImportInformationCard->Call($fileName);
# fileName : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。