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. how can i change machain date

how can i change machain date

Scheduled Pinned Locked Moved C#
helpquestion
7 Posts 4 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.
  • M Offline
    M Offline
    Mohammed Elkholy
    wrote on last edited by
    #1

    Hi everybody i want to change machain datetime ,but i dont how thanks for help

    MD_NADA

    M V L 3 Replies Last reply
    0
    • M Mohammed Elkholy

      Hi everybody i want to change machain datetime ,but i dont how thanks for help

      MD_NADA

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      md_nada wrote:

      i want to change machain datetime ,but i dont how

      Follow the following steps: 1. Open Notepad 2. Go to Format->Font. Select your favourite font. 3. Look at the time on the Wall Clock at your home/office and write it in on the NotePad. 4. Save the file at C:\ drive with name currenttime.txt. Or did you expect any other answer ;P

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      M 1 Reply Last reply
      0
      • M Mohammed Elkholy

        Hi everybody i want to change machain datetime ,but i dont how thanks for help

        MD_NADA

        V Offline
        V Offline
        varun_mca_ju 0
        wrote on last edited by
        #3

        see the extreme bottom-right of your computer screen(where the system time is displayed),double click the system time being displayed...and make the changes :)

        1 Reply Last reply
        0
        • M Mohammed Elkholy

          Hi everybody i want to change machain datetime ,but i dont how thanks for help

          MD_NADA

          L Offline
          L Offline
          lisan_al_ghaib
          wrote on last edited by
          #4

          Hello you can do this using some Win32 API functions (warning : unmanaged code) please see this : http://bytes.com/forum/thread242372.html[^]

          M 1 Reply Last reply
          0
          • M Manas Bhardwaj

            md_nada wrote:

            i want to change machain datetime ,but i dont how

            Follow the following steps: 1. Open Notepad 2. Go to Format->Font. Select your favourite font. 3. Look at the time on the Wall Clock at your home/office and write it in on the NotePad. 4. Save the file at C:\ drive with name currenttime.txt. Or did you expect any other answer ;P

            Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

            M Offline
            M Offline
            Mohammed Elkholy
            wrote on last edited by
            #5

            hi maybe i was not clear , i mean change machain date programaticlly using C#

            MD_NADA

            1 Reply Last reply
            0
            • L lisan_al_ghaib

              Hello you can do this using some Win32 API functions (warning : unmanaged code) please see this : http://bytes.com/forum/thread242372.html[^]

              M Offline
              M Offline
              Mohammed Elkholy
              wrote on last edited by
              #6

              thnx for ur help but i try this code but it dosent work

              MD_NADA

              L 1 Reply Last reply
              0
              • M Mohammed Elkholy

                thnx for ur help but i try this code but it dosent work

                MD_NADA

                L Offline
                L Offline
                lisan_al_ghaib
                wrote on last edited by
                #7

                There is a little fix : correct solution

                public class Win32
                {
                private Win32()
                {
                }

                    \[StructLayout(LayoutKind.Sequential)\]
                    public struct SystemTime
                    {
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short Year;
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short Month;
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short DayOfWeek;
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short Day;
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short Hour;
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short Minute;
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short Second;
                        \[MarshalAs(UnmanagedType.U2)\]
                        public short Milliseconds;
                    }
                
                    \[DllImport("kernel32.dll")\]
                    public static extern void GetLocalTime(
                    out SystemTime systemTime);
                
                    \[DllImport("kernel32.dll")\]
                    public static extern void GetSystemTime(
                    out SystemTime systemTime);
                
                    \[DllImport("kernel32.dll")\]
                    public static extern bool SetSystemTime(
                    ref SystemTime systemTime);
                
                    \[DllImport("kernel32.dll")\]
                    public static extern bool SetLocalTime(
                    ref SystemTime systemTime);
                }
                

                ....
                in you method do this :
                Win32.SystemTime sysTime;

                        sysTime.Day = 13;
                       // do all needed modification on date and time...
                       //....
                
                        Win32.SetSystemTime(ref sysTime);
                

                Make sure that you got admin rights.

                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