注册表项的最后写入时间

3

使用 Microsoft.Win32.RegistryKey(或任何相关类),我该如何查询注册表键的最后写入时间?


2
你做不到。Windows 不跟踪单个键的“修改时间”。 - paulsm4
@paulsm4 你不能使用RegQueryInfoKey WinAPI函数吗?虽然我尝试查看是否有一些本地的.NET方法来实现这一点。 - Josh
1
@paulsm4 这不是真的。创建时间没有被存储,但最后修改时间是有的。 - Jason Watkins
根据下面的答案,您可以这样做。 - Daniel Kelley
1个回答

8
您需要使用P/Invoke来调用Win32 API: MSDN: RegQueryInfoKey函数Pinvoke.net中获取签名:
[DllImport("advapi32.dll", EntryPoint="RegQueryInfoKey", CallingConvention=CallingConvention.Winapi, SetLastError=true)]
extern private static int RegQueryInfoKey(
    UIntPtr hkey,
    out StringBuilder lpClass,
    ref uint lpcbClass,
    IntPtr lpReserved,
    out uint lpcSubKeys,
    out uint lpcbMaxSubKeyLen,
    out uint lpcbMaxClassLen,
    out uint lpcValues,
    out uint lpcbMaxValueNameLen,
    out uint lpcbMaxValueLen,
    out uint lpcbSecurityDescriptor,
    IntPtr lpftLastWriteTime);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接