Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello everyone
i want to know how can i obtain time now without use class DateTime

i try to create my special class date

thanks for your answer :)
Posted
Comments
Sergey Alexandrovich Kryukov 18-Nov-12 0:16am    
Why without?! :-)
What would be the purpose of this class?
--SA
Pro Idiot 18-Nov-12 2:01am    
Same qs :) , Why not use an existing function

1 solution

If you are using a .NET language, then you should use .NET functions - you could get the time by PInvoke of GetSystemTime[^]:
C#
[DllImport("kernel32.dll")]
static extern void GetSystemTime(out SYSTEMTIME lpSystemTime);
But then you need to declare the SYSTEMTIME structure and process it yourself.
C#
[StructLayout(LayoutKind.Sequential)]
public class SystemTime
{
   public ushort year;
   ...
   public ushort milliseconds;
}

Providing a wrapper class for the DateTime.Now property would be a better solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900