cheers, this is my last post on the topic and thank you for your patients and help, I'm appreciating it!
Your advice has got the time and date displaying correctly but I just need to check which key I'm getting the time for as I feel it may be the wrong one as all the times and dates are displaying the same.
When I pass 'hKey' to my program, is that not passing the key HKEY_LOCAL_MACHINE and therefore I am reading the lastwritten time of this key everytime in my loop thats why its the same every time?
As my value 'buf' contains the full path to the key I want to query the lastwritten time, do I need to pass this?
thank you
Code:
HKEY hKey = 0;
char buf[255] = {0};
DWORD dwBufSize = sizeof(buf);
const char* subkey = "SYSTEM\\CurrentControlSet\\Enum\\USBSTOR";
string path = "SYSTEM\\CurrentControlSet\\Enum\\USBSTOR\\";
if( RegOpenKey(HKEY_LOCAL_MACHINE,subkey,&hKey) == ERROR_SUCCESS)
{
int i = 0;
while(RegEnumKeyEx(hKey, i++, buf, &dwBufSize, 0, 0, 0, 0) == ERROR_SUCCESS)
{
cout << "Found Key Value Name: " << buf << endl;
dwBufSize = sizeof(buf);
string bufish = buf;
string nextkey = path +bufish;
cout << nextkey << endl;
FILETIME writeTime;
RegQueryInfoKey(hKey,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,&writeTime);
SYSTEMTIME st;
FileTimeToSystemTime( &writeTime, &st );
cout << st.wYear << "/"
<< st.wDay << "/"
<< st.wMonth << " "
<< st.wHour << ":"
<< st.wMinute << ":"
<< st.wSecond << ":"
<< st.wMilliseconds ;