Click here to Skip to main content
16,005,037 members
Home / Discussions / C#
   

C#

 
GeneralRemoving Icon from a Form Pin
Luis Alonso Ramos3-Aug-05 9:41
Luis Alonso Ramos3-Aug-05 9:41 
GeneralRe: Removing Icon from a Form Pin
Dave Kreskowiak3-Aug-05 11:52
mveDave Kreskowiak3-Aug-05 11:52 
GeneralRe: Removing Icon from a Form Pin
Lars Niedziolka3-Aug-05 13:02
Lars Niedziolka3-Aug-05 13:02 
GeneralRe: Removing Icon from a Form Pin
Luis Alonso Ramos3-Aug-05 13:06
Luis Alonso Ramos3-Aug-05 13:06 
GeneralRe: Removing Icon from a Form Pin
Luis Alonso Ramos3-Aug-05 13:05
Luis Alonso Ramos3-Aug-05 13:05 
GeneralRe: Removing Icon from a Form Pin
Lars Niedziolka3-Aug-05 13:50
Lars Niedziolka3-Aug-05 13:50 
GeneralRe: Removing Icon from a Form Pin
Luis Alonso Ramos3-Aug-05 13:54
Luis Alonso Ramos3-Aug-05 13:54 
GeneralConverting Server to Local Time Pin
Anonymous3-Aug-05 8:32
Anonymous3-Aug-05 8:32 
Hi all,

I need to update client machines with the correct time if it is inaccurate. The server I'm using will always have the correct time so I'll be using that as the source of correct time. The code below works most of the time but is an an hour off sometimes (daylightsavings time).

For example, If I change the date on a local to machine to Jan 2005, my code will update the time an hour ahead of where it should be. Any help would be appreciated.

Thanks,Paul

Code is below

using System;
using System.Runtime.InteropServices;

public void UpdateTime(DateTime ServerTime)
{
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime localTime = localZone.ToLocalTime(ServerTime);
TimeSpan localOffset = localZone.GetUtcOffset(localTime );
ServerTime = ServerTime.Add(localOffset);
SetTime(ServerTime);
}

[StructLayoutAttribute(LayoutKind.Sequential)]
private 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;
}

[DllImport("kernel32.dll")]
static extern bool SetLocalTime(ref SYSTEMTIME time);

private void SetTime(DateTime NewTime)
{
SYSTEMTIME st;
st.year = (short)NewTime.Year;
st.month = (short)NewTime.Month;
st.dayOfWeek = (short)NewTime.DayOfWeek;
st.day = (short)NewTime.Day;
st.hour = (short)NewTime.Hour;
st.minute = (short)NewTime.Minute;
st.second = (short)NewTime.Second;
st.milliseconds = (short)NewTime.Millisecond;
SetLocalTime(ref st);
}
GeneralJavascript from c# Pin
Renjith Ramachandran3-Aug-05 7:59
Renjith Ramachandran3-Aug-05 7:59 
GeneralRe: Javascript from c# Pin
Judah Gabriel Himango3-Aug-05 8:06
sponsorJudah Gabriel Himango3-Aug-05 8:06 
GeneralIntegrating C# library in C++ service Pin
Francois Dubé3-Aug-05 7:43
sussFrancois Dubé3-Aug-05 7:43 
GeneralRe: Integrating C# library in C++ service Pin
Rob Graham3-Aug-05 9:15
Rob Graham3-Aug-05 9:15 
GeneralRe: Integrating C# library in C++ service Pin
Member 104401004-Aug-05 5:27
Member 104401004-Aug-05 5:27 
GeneralAppend Text to Notepad programatically Pin
Alomgir Miah3-Aug-05 7:27
Alomgir Miah3-Aug-05 7:27 
GeneralRe: Append Text to Notepad programatically Pin
Guffa3-Aug-05 7:33
Guffa3-Aug-05 7:33 
GeneralRe: Append Text to Notepad programatically Pin
Alomgir Miah3-Aug-05 7:36
Alomgir Miah3-Aug-05 7:36 
GeneralRe: Append Text to Notepad programatically Pin
Luis Alonso Ramos3-Aug-05 9:42
Luis Alonso Ramos3-Aug-05 9:42 
Generalusing a c++ .lib file Pin
Anonymous3-Aug-05 7:06
Anonymous3-Aug-05 7:06 
GeneralRe: using a c++ .lib file Pin
S. Senthil Kumar3-Aug-05 7:17
S. Senthil Kumar3-Aug-05 7:17 
GeneralMethod "Export" of CrystalReport Pin
DevC#3-Aug-05 6:42
DevC#3-Aug-05 6:42 
GeneralI spent 2 hours seardhing for an answer... Pin
Anonymous3-Aug-05 6:02
Anonymous3-Aug-05 6:02 
GeneralRe: I spent 2 hours seardhing for an answer... Pin
Judah Gabriel Himango3-Aug-05 8:10
sponsorJudah Gabriel Himango3-Aug-05 8:10 
GeneralView update pattern Pin
ppp0013-Aug-05 5:49
ppp0013-Aug-05 5:49 
GeneralRe: View update pattern Pin
Patric_J3-Aug-05 8:31
Patric_J3-Aug-05 8:31 
GeneralRe: View update pattern Pin
ppp0013-Aug-05 13:13
ppp0013-Aug-05 13:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.