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#
  4. SetDate of system from inside of our program

SetDate of system from inside of our program

Scheduled Pinned Locked Moved C#
questionannouncement
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.
  • F Offline
    F Offline
    Fred 34
    wrote on last edited by
    #1

    [DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
    public extern static bool Win32SetSystemTime(ref SystemTime sysTime);

    By the above code I can change the system date of many version of MicroSoft Windows 7, but doesn't work on all of them. Do I miss something?

    P D 2 Replies Last reply
    0
    • F Fred 34

      [DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
      public extern static bool Win32SetSystemTime(ref SystemTime sysTime);

      By the above code I can change the system date of many version of MicroSoft Windows 7, but doesn't work on all of them. Do I miss something?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      As this call requires the SE_SYSTEMTIME_NAME privilege, I suspect you've hit a permissions issue.

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      1 Reply Last reply
      0
      • F Fred 34

        [DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
        public extern static bool Win32SetSystemTime(ref SystemTime sysTime);

        By the above code I can change the system date of many version of MicroSoft Windows 7, but doesn't work on all of them. Do I miss something?

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Only an administrator account can change the system time. If your code is launched by a normal user it's not going to work.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        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