View Full Version : تغییر زمان در ویندوز
  
tanha70
یک شنبه 13 اردیبهشت 1394, 15:00 عصر
سلام
دوستان من میخوام یه تابع داشتم که به عنوان ورودی یه DateTime بگیره و زمان سیستم رو به زمان ورودی که گرفته تغییر بده.
ممنون میشم در این مورد راهنمایی بفرماید.
Mofid.m
یک شنبه 13 اردیبهشت 1394, 15:05 عصر
درود به شما
یه نگاهی یه این لینک بکن.
https://msdn.microsoft.com/en-us/library/ms172517(v=vs.90).aspx
tanha70
جمعه 18 اردیبهشت 1394, 17:41 عصر
متاسفانه این کارمو راه ننداخت.
الان یه کد دیگه پیدا کردم ولی ارور داره.
class TimeWork
    {
        [DllImport("coredll.dll", SetLastError = true)]
        static extern bool SetLocalTime(ref SYSTEMTIME lpSystemTime);
        [DllImport("coredll.dll")]
        private extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);
        public struct SYSTEMTIME
        {
            public short year;
            public short month;
            public short dayOfWeek;
            public short day;
            public short hour;
            public short minute;
            public short second;
            public short milliseconds;
        }
        //And this is the final method to execute
        public static void SetSystemDateTime(DateTime dt)
        {
            SYSTEMTIME systime;
            systime.year = (short)dt.Year;
            systime.month = (short)dt.Month;
            systime.day = (short)dt.Day;
            systime.hour = (short)dt.Hour;
            systime.minute = (short)dt.Minute;
            systime.second = (short)dt.Second;
            systime.milliseconds = (short)dt.Millisecond;
            systime.dayOfWeek = (short)dt.DayOfWeek;
            SetLocalTime(ref systime);
        }
    }
ارورش هم از خط زیر گرفته میشه
SetLocalTime(ref systime);
متن ارور:
Unable to load DLL 'coredll.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.