Solved

How Change Date Time in WinXP ?

Posted on 2004-10-23
166 Views
Last Modified: 2012-05-05
Hallo Experts :)

Can you please help me how to change Date & Time in Windows XP ?

Thank You so much for your attention :)
0
Question by:comicboy
    1 Comment
     
    LVL 9

    Accepted Solution

    by:
    function SetPCSystemTime(dDateTime: TDateTime): Boolean;
    const
      SE_SYSTEMTIME_NAME = 'SeSystemtimePrivilege';
    var
      hToken: THandle;
      ReturnLength: DWORD;
      tkp, PrevTokenPriv: TTokenPrivileges;
      luid: TLargeInteger;
      dSysTime: TSystemTime;
    begin
      Result := False;
      if (Win32Platform = VER_PLATFORM_WIN32_NT) then
      begin
        if OpenProcessToken(GetCurrentProcess,
          TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
        begin
          try
            if not LookupPrivilegeValue(nil, SE_SYSTEMTIME_NAME, luid) then Exit;
            tkp.PrivilegeCount := 1;
            tkp.Privileges[0].luid := luid;
            tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
            if not AdjustTokenPrivileges(hToken, False, tkp, SizeOf(TTOKENPRIVILEGES),
              PrevTokenPriv, ReturnLength) then
              Exit;
            if (GetLastError <> ERROR_SUCCESS) then
            begin
              raise Exception.Create(SysErrorMessage(GetLastError));
              Exit;
            end;
          end;
        finally
          CloseHandle(hToken);
        end;
      end;
      DateTimeToSystemTime(dDateTime, dSysTime);
      Windows.SetLocalTime(dSysTime);
    end;
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Lean Six Sigma Project Manager Certification

    There are many schools of thought around successful project management, but few as highly regarded as the Six Sigma and Lean methods. With 37 hours of learning, this training will explain concrete processes for increasing efficiency and limiting wasted time and effort.

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now