ホーム › Globalization › ucal_getNow
ucal_getNow
関数現在時刻をUTCのミリ秒として取得する。
シグネチャ
// icuin.dll
#include <windows.h>
DOUBLE ucal_getNow(void);パラメーターなし。戻り値: DOUBLE
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
DOUBLE ucal_getNow(void);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern double ucal_getNow();<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucal_getNow() As Double
End FunctionDeclare PtrSafe Function ucal_getNow Lib "icuin" () As Double
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucal_getNow = ctypes.cdll.icuin.ucal_getNow
ucal_getNow.restype = ctypes.c_double
ucal_getNow.argtypes = []require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
ucal_getNow = Fiddle::Function.new(
lib['ucal_getNow'],
[],
Fiddle::TYPE_DOUBLE, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn ucal_getNow() -> f64;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern double ucal_getNow();
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_ucal_getNow' -Namespace Win32 -PassThru
# $api::ucal_getNow()#uselib "icuin.dll"
#func global ucal_getNow "ucal_getNow"
; ucal_getNow ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "icuin.dll"
#cfunc global ucal_getNow "ucal_getNow"
; res = ucal_getNow(); DOUBLE ucal_getNow()
#uselib "icuin.dll"
#cfunc global ucal_getNow "ucal_getNow"
; res = ucal_getNow()import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procucal_getNow = icuin.NewProc("ucal_getNow")
)
r1, _, err := procucal_getNow.Call()
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DOUBLEfunction ucal_getNow: Double; cdecl;
external 'icuin.dll' name 'ucal_getNow';result := DllCall("icuin\ucal_getNow", "Cdecl Double")●ucal_getNow() = DLL("icuin.dll", "double ucal_getNow()")
# 呼び出し: ucal_getNow()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icuin" fn ucal_getNow() callconv(.c) f64;proc ucal_getNow(): float64 {.importc: "ucal_getNow", cdecl, dynlib: "icuin.dll".}pragma(lib, "icuin");
extern(C)
double ucal_getNow();ccall((:ucal_getNow, "icuin.dll"), Float64,
(),
)local ffi = require("ffi")
ffi.cdef[[
double ucal_getNow(void);
]]
local icuin = ffi.load("icuin")
-- icuin.ucal_getNow()
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const ucal_getNow = lib.func('__cdecl', 'ucal_getNow', 'double', []);
// ucal_getNow()
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuin.dll", {
ucal_getNow: { parameters: [], result: "f64" },
});
// lib.symbols.ucal_getNow()
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
double ucal_getNow(void);
C, "icuin.dll");
// $ffi->ucal_getNow();
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icuin extends Library {
Icuin INSTANCE = Native.load("icuin", Icuin.class);
double ucal_getNow();
}@[Link("icuin")]
lib Libicuin
fun ucal_getNow = ucal_getNow() : Float64
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucal_getNowNative = Double Function();
typedef ucal_getNowDart = double Function();
final ucal_getNow = DynamicLibrary.open('icuin.dll')
.lookupFunction<ucal_getNowNative, ucal_getNowDart>('ucal_getNow');
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucal_getNow: Double; cdecl;
external 'icuin.dll' name 'ucal_getNow';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucal_getNow"
c_ucal_getNow :: IO CDouble
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucal_getnow =
foreign "ucal_getNow"
(void @-> returning double)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)
(cffi:defcfun ("ucal_getNow" ucal-get-now :convention :cdecl) :double)
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucal_getNow = Win32::API::More->new('icuin',
'double ucal_getNow()');
# my $ret = $ucal_getNow->Call();
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。