Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetSystemTime(LPSYSTEMTIME st)

GetSystemTime(LPSYSTEMTIME st)

Scheduled Pinned Locked Moved C / C++ / MFC
questionworkspace
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jnewg5
    wrote on last edited by
    #1

    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.

    N R 2 Replies Last reply
    0
    • J Jnewg5

      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.

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      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"

      1 Reply Last reply
      0
      • J Jnewg5

        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.

        R Offline
        R Offline
        rwestgraham
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups