使用 Microsoft.Win32.RegistryKey(或任何相关类),如何查询注册表项的上次写入时间?

最佳答案

您将需要使用 P/Invoke 来调用 Win32 API:

MSDN: RegQueryInfoKey function

来自 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);

关于c# - RegistryKey 上次写入时间,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15621053/

10-13 23:23