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