Results 1 to 2 of 2

Thread: Determine which registry key is newer (RegEnumKeyEx?) [C# 2002]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Posts
    308

    Question Determine which registry key is newer (RegEnumKeyEx?) [C# 2002]

    I'm converting code from VC++6 to VC#2002 and have encountered my first roadblock with respect to using "RegEnumKeyEx" to compare the time stamps of registry

    keys (when they were created to find the newest one).

    Currently I do the following in VC++6 to determine which key is the newest:
    Code:
       FILETIME ft, mrft; // mr = most recent
       mrft.dwLowDateTime = 0;
       mrft.dwHighDateTime = 0;
    
       while (ERROR_SUCCESS == (rc = RegEnumKeyEx( hkBase,
                                           Index++,
                                           Name,
                                           &Length,
                                           NULL,
                                           NULL,
                                           NULL,
                                           &ft))))
          {
          if (CompareFileTime (&mrft, &ft))
             {
             mrft.dwLowDateTime = ft.dwLowDateTime;
             mrft.dwHighDateTime = ft.dwHighDateTime;
             newestName = Name;
             }
       }
       ...
       ...
    So my problem is how to accomplish this in C#?
    Is there an alternative approach I should be using under the DotNet platform for C#? Or is there a way I can include "RegEnumKeyEx" somehow (like I would do a DECLARE with coredll.dll in VB or something) in the C# project so I can use the function as-is (continue the same way I was before)?

    Any help would be greatly appreciated.
    Thanks,

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: Determine which registry key is newer (RegEnumKeyEx?) [C# 2002]

    Hi there,
    I can't find anything in the documentation that speaks about retrieving a Registry key's last write time, but that certainly doesn't mean that it isn't there.

    Anyway, here is your equivalent of Declare in VB.NET is DllImport:
    http://msdn2.microsoft.com/en-us/lib...36(VS.71).aspx

    You may want to also check this out as it looks like it has the function you want:
    http://www.dnzone.com/ShowDetail.asp?NewsId=618

    Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width