ホーム › Networking.WinInet › InternetTimeToSystemTimeW
InternetTimeToSystemTimeW
関数インターネット日付形式の文字列をSYSTEMTIMEに変換する(Unicode)。
シグネチャ
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL InternetTimeToSystemTimeW(
LPCWSTR lpszTime,
SYSTEMTIME* pst,
DWORD dwReserved // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpszTime | LPCWSTR | in |
| pst | SYSTEMTIME* | out |
| dwReserved | DWORD | optional |
戻り値の型: BOOL
各言語での呼び出し定義
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL InternetTimeToSystemTimeW(
LPCWSTR lpszTime,
SYSTEMTIME* pst,
DWORD dwReserved // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool InternetTimeToSystemTimeW(
[MarshalAs(UnmanagedType.LPWStr)] string lpszTime, // LPCWSTR
IntPtr pst, // SYSTEMTIME* out
uint dwReserved // DWORD optional
);<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetTimeToSystemTimeW(
<MarshalAs(UnmanagedType.LPWStr)> lpszTime As String, ' LPCWSTR
pst As IntPtr, ' SYSTEMTIME* out
dwReserved As UInteger ' DWORD optional
) As Boolean
End Function' lpszTime : LPCWSTR
' pst : SYSTEMTIME* out
' dwReserved : DWORD optional
Declare PtrSafe Function InternetTimeToSystemTimeW Lib "wininet" ( _
ByVal lpszTime As LongPtr, _
ByVal pst As LongPtr, _
ByVal dwReserved As Long) As Long
' 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
InternetTimeToSystemTimeW = ctypes.windll.wininet.InternetTimeToSystemTimeW
InternetTimeToSystemTimeW.restype = wintypes.BOOL
InternetTimeToSystemTimeW.argtypes = [
wintypes.LPCWSTR, # lpszTime : LPCWSTR
ctypes.c_void_p, # pst : SYSTEMTIME* out
wintypes.DWORD, # dwReserved : DWORD optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
InternetTimeToSystemTimeW = Fiddle::Function.new(
lib['InternetTimeToSystemTimeW'],
[
Fiddle::TYPE_VOIDP, # lpszTime : LPCWSTR
Fiddle::TYPE_VOIDP, # pst : SYSTEMTIME* out
-Fiddle::TYPE_INT, # dwReserved : DWORD optional
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wininet")]
extern "system" {
fn InternetTimeToSystemTimeW(
lpszTime: *const u16, // LPCWSTR
pst: *mut SYSTEMTIME, // SYSTEMTIME* out
dwReserved: u32 // DWORD optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool InternetTimeToSystemTimeW([MarshalAs(UnmanagedType.LPWStr)] string lpszTime, IntPtr pst, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetTimeToSystemTimeW' -Namespace Win32 -PassThru
# $api::InternetTimeToSystemTimeW(lpszTime, pst, dwReserved)#uselib "WININET.dll"
#func global InternetTimeToSystemTimeW "InternetTimeToSystemTimeW" wptr, wptr, wptr
; InternetTimeToSystemTimeW lpszTime, varptr(pst), dwReserved ; 戻り値は stat
; lpszTime : LPCWSTR -> "wptr"
; pst : SYSTEMTIME* out -> "wptr"
; dwReserved : DWORD optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global InternetTimeToSystemTimeW "InternetTimeToSystemTimeW" wstr, var, int ; res = InternetTimeToSystemTimeW(lpszTime, pst, dwReserved) ; lpszTime : LPCWSTR -> "wstr" ; pst : SYSTEMTIME* out -> "var" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global InternetTimeToSystemTimeW "InternetTimeToSystemTimeW" wstr, sptr, int ; res = InternetTimeToSystemTimeW(lpszTime, varptr(pst), dwReserved) ; lpszTime : LPCWSTR -> "wstr" ; pst : SYSTEMTIME* out -> "sptr" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL InternetTimeToSystemTimeW(LPCWSTR lpszTime, SYSTEMTIME* pst, DWORD dwReserved) #uselib "WININET.dll" #cfunc global InternetTimeToSystemTimeW "InternetTimeToSystemTimeW" wstr, var, int ; res = InternetTimeToSystemTimeW(lpszTime, pst, dwReserved) ; lpszTime : LPCWSTR -> "wstr" ; pst : SYSTEMTIME* out -> "var" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL InternetTimeToSystemTimeW(LPCWSTR lpszTime, SYSTEMTIME* pst, DWORD dwReserved) #uselib "WININET.dll" #cfunc global InternetTimeToSystemTimeW "InternetTimeToSystemTimeW" wstr, intptr, int ; res = InternetTimeToSystemTimeW(lpszTime, varptr(pst), dwReserved) ; lpszTime : LPCWSTR -> "wstr" ; pst : SYSTEMTIME* out -> "intptr" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procInternetTimeToSystemTimeW = wininet.NewProc("InternetTimeToSystemTimeW")
)
// lpszTime (LPCWSTR), pst (SYSTEMTIME* out), dwReserved (DWORD optional)
r1, _, err := procInternetTimeToSystemTimeW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszTime))),
uintptr(pst),
uintptr(dwReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InternetTimeToSystemTimeW(
lpszTime: PWideChar; // LPCWSTR
pst: Pointer; // SYSTEMTIME* out
dwReserved: DWORD // DWORD optional
): BOOL; stdcall;
external 'WININET.dll' name 'InternetTimeToSystemTimeW';result := DllCall("WININET\InternetTimeToSystemTimeW"
, "WStr", lpszTime ; LPCWSTR
, "Ptr", pst ; SYSTEMTIME* out
, "UInt", dwReserved ; DWORD optional
, "Int") ; return: BOOL●InternetTimeToSystemTimeW(lpszTime, pst, dwReserved) = DLL("WININET.dll", "bool InternetTimeToSystemTimeW(char*, void*, dword)")
# 呼び出し: InternetTimeToSystemTimeW(lpszTime, pst, dwReserved)
# lpszTime : LPCWSTR -> "char*"
# pst : SYSTEMTIME* out -> "void*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。