| | |
How can i access Time from Server ?
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: May 2005
Posts: 514
Reputation:
Solved Threads: 19
API DECLARTIONS
MODULE
Usage
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit 'API Structures 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 'NetAPI Calls Public 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 'Kernel API Calls Private Declare Sub CopyMem Lib "kernel32.dll" Alias "RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)
MODULE
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'Return the Time and Date of a specified Machine on the Net 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 'Local machine ret = NetRemoteTOD(vbNullString, lpBuffer) Else 'Check the syntax of the ServerName string 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
Usage
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'Get the time and date of the local machine Private Sub Command1_Click() MsgBox GetRemoteTime("") End Sub 'Get the time and date a remote Workstation Private Sub Command2_Click() MsgBox GetRemoteTime("\\MYWORKSTATION") End Sub
•
•
Join Date: Oct 2005
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by techniner
API DECLARTIONS
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit 'API Structures 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 'NetAPI Calls Public 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 'Kernel API Calls Private Declare Sub CopyMem Lib "kernel32.dll" Alias "RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)
MODULE
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'Return the Time and Date of a specified Machine on the Net 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 'Local machine ret = NetRemoteTOD(vbNullString, lpBuffer) Else 'Check the syntax of the ServerName string 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
Usage
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'Get the time and date of the local machine Private Sub Command1_Click() MsgBox GetRemoteTime("") End Sub 'Get the time and date a remote Workstation Private Sub Command2_Click() MsgBox GetRemoteTime("\\MYWORKSTATION") End Sub
This code is running in NT, XP machine. but when exe in executed from win98 then database in updating the field with 01-01-1900. Please help me how to get time from server when we r working in win98
![]() |
Similar Threads
- Access & MS SQL Server 2005 (MS SQL)
- ow can i access Time from Server (Visual Basic 4 / 5 / 6)
- how to set file access time (C)
- How many clients can access a PHP script at a time from a MySQL server? (MySQL)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: vb6 error help me
- Next Thread: pictureBox problem.. please help me!
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





