GetSystemTime(LPSYSTEMTIME st)
-
Can this function call fail in some configuration of Windows NT 4.0 and later? The docs state that the complementary SetSystemTime call will fail if the user doesn't have the privileges to set the time on a system. I have an application that is failing to return this information. The function is void, so the only real valid check is to check the SYSTEMTIME struct for empty values.
-
Can this function call fail in some configuration of Windows NT 4.0 and later? The docs state that the complementary SetSystemTime call will fail if the user doesn't have the privileges to set the time on a system. I have an application that is failing to return this information. The function is void, so the only real valid check is to check the SYSTEMTIME struct for empty values.
It is very hard to believe that GetSystemTime() could fail and I certainly have never seen it. MSDN and Googling don't show anything like this. It could be worth testing GetLastError() even though doc's don't mention it is relevant. Also try GetLocalTime() and time(NULL). Maybe your code is clobbering the SYSTEMTIME struct. Are you checking it directly after the call to GetSystemTime() or later on? Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
Can this function call fail in some configuration of Windows NT 4.0 and later? The docs state that the complementary SetSystemTime call will fail if the user doesn't have the privileges to set the time on a system. I have an application that is failing to return this information. The function is void, so the only real valid check is to check the SYSTEMTIME struct for empty values.
Are you passing the SYSTEMTIME structure in correctly? The structure has to be an [out] parameter. So you need to call the API with the pointer to the structure. This will NOT work: //////////////////////////////////////// //Declare a SYSTEMTIME structure SYSTEMTIME stSystemTime; //Call GetSystemTime GetSystemTime(stSystemTime); //////////////////////////////////////// Instead you should call something like this: //////////////////////////////////////// //Declare a SYSTEMTIME structure SYSTEMTIME stSystemTime; //Call GetSystemTime GetSystemTime(&stSystemTime); //////////////////////////////////////// Good Luck, Robert