Click here to Skip to main content
15,886,963 members
Home / Discussions / C#
   

C#

 
GeneralThread problem Pin
azusakt30-Apr-04 0:44
azusakt30-Apr-04 0:44 
GeneralRe: Thread problem Pin
Corinna John30-Apr-04 1:41
Corinna John30-Apr-04 1:41 
GeneralRe: Thread problem Pin
Jan Vercauteren30-Apr-04 2:49
Jan Vercauteren30-Apr-04 2:49 
GeneralRe: Thread problem Pin
Heath Stewart30-Apr-04 3:53
protectorHeath Stewart30-Apr-04 3:53 
Generalupdating system time in c# Pin
bennyrascal30-Apr-04 0:37
bennyrascal30-Apr-04 0:37 
GeneralRe: updating system time in c# Pin
John Baird30-Apr-04 2:47
John Baird30-Apr-04 2:47 
GeneralRe: updating system time in c# Pin
bennyrascal30-Apr-04 3:21
bennyrascal30-Apr-04 3:21 
GeneralRe: updating system time in c# Pin
Heath Stewart30-Apr-04 3:59
protectorHeath Stewart30-Apr-04 3:59 
You have to ref the SYSTEMTIME structure. VB is passing a reference to it, but you're passing its value. The SetSystemTime API requires a SYSTEMTIME* (pointer to a SYSTEMTIME struct), so your P/Invoke declaration should look like:
[DllImport("kernel32.dll")]
private static extern bool SetSystemTime(ref SYSTEMTIME systime);
Also, you do not typically make P/Invoke methods public because it creates holes in your application that could be used to corrupt the system or your application. Besides, do you want to create that struct every time you want to call it? A better method would be to expose a public method that takes a DateTime, does the conversion and calls the private P/Invoke method above. You've already done this, but you should make your P/Invoke method private, not public. It's all about encapsulation.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: updating system time in c# Pin
bennyrascal30-Apr-04 14:20
bennyrascal30-Apr-04 14:20 
GeneralInvoking Console Application at runtime Pin
Aryadip29-Apr-04 23:28
Aryadip29-Apr-04 23:28 
GeneralRe: Invoking Console Application at runtime Pin
leppie30-Apr-04 7:08
leppie30-Apr-04 7:08 
GeneralRe: Invoking Console Application at runtime Pin
Aryadip4-May-04 20:24
Aryadip4-May-04 20:24 
GeneralArchitectural question (crisis) Pin
Jan Vercauteren29-Apr-04 21:48
Jan Vercauteren29-Apr-04 21:48 
GeneralRe: Architectural question (crisis) Pin
Anonymous29-Apr-04 23:05
Anonymous29-Apr-04 23:05 
GeneralRe: Architectural question (crisis) Pin
Anonymous29-Apr-04 23:06
Anonymous29-Apr-04 23:06 
GeneralRe: Architectural question (crisis) Pin
Jan Vercauteren30-Apr-04 0:37
Jan Vercauteren30-Apr-04 0:37 
GeneralRe: Architectural question (crisis) Pin
bjoernen30-Apr-04 1:54
bjoernen30-Apr-04 1:54 
GeneralRe: Architectural question (crisis) Pin
Jan Vercauteren30-Apr-04 2:46
Jan Vercauteren30-Apr-04 2:46 
GeneralRe: Architectural question (crisis) Pin
Heath Stewart30-Apr-04 4:05
protectorHeath Stewart30-Apr-04 4:05 
GeneralRe: Architectural question (crisis) Pin
Jan Vercauteren30-Apr-04 4:55
Jan Vercauteren30-Apr-04 4:55 
GeneralRe: Architectural question (crisis) Pin
Heath Stewart30-Apr-04 5:10
protectorHeath Stewart30-Apr-04 5:10 
GeneralRe: Architectural question (crisis) Pin
bjoernen30-Apr-04 11:51
bjoernen30-Apr-04 11:51 
GeneralRe: Architectural question (crisis) Pin
Jan Vercauteren30-Apr-04 13:07
Jan Vercauteren30-Apr-04 13:07 
GeneralStupid string to int question Pin
Anonymous29-Apr-04 20:53
Anonymous29-Apr-04 20:53 
GeneralRe: Stupid string to int question Pin
Anonymous29-Apr-04 21:05
Anonymous29-Apr-04 21:05 

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.