|
|
|
Step-By-Step Example
- Create a standard exe project - Add the following code in form1 |
Click here to copy the following block | Private Type TIME_OF_DAY_INFO tod_elapsed As Long tod_msecs As Long tod_hours As Long tod_mins As Long tod_secs As Long tod_hunds As Long tod_timezone As Long tod_tinterval As Long tod_day As Long tod_month As Long tod_year As Long tod_weekday As Long End Type
Private Declare Function NetRemoteTOD Lib "netapi32.dll" ( _ yServer As Any, pBuffer As Long) As Long Private Declare Function NetApiBufferFree Lib "netapi32.dll" ( _ ByVal pBuffer As Long) As Long
Private Declare Sub CopyMem Lib "kernel32.dll" Alias "RtlMoveMemory" ( _ pTo As Any, uFrom As Any, ByVal lSize As Long)
Public Function GetRemoteTime(servername As String) As Date Dim lpBuffer As Long Dim t_struct As TIME_OF_DAY_INFO Dim ret As Long Dim bServer() As Byte
If Trim(servername) = "" Then ret = NetRemoteTOD(vbNullString, lpBuffer) Else If InStr(servername, "\\") = 1 Then bServer = servername & vbNullChar Else bServer = "\\" & servername & vbNullChar End If ret = NetRemoteTOD(bServer(0), lpBuffer) End If CopyMem t_struct, ByVal lpBuffer, Len(t_struct) If lpBuffer Then Call NetApiBufferFree(lpBuffer) End If GetRemoteTime = DateSerial(t_struct.tod_year, _ t_struct.tod_month, _ t_struct.tod_day) _ + TimeSerial(t_struct.tod_hours, _ t_struct.tod_mins - t_struct.tod_timezone, _ t_struct.tod_secs) End Function
Private Sub Command1_Click() MsgBox GetRemoteTime("") End Sub
Private Sub Form_Load() Dim servername servername = InputBox("Please enter name of the server") MsgBox "Current time on " & servername & " is : " & _ GetRemoteTime("\\" & servername) End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|