Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!! how to get server date 2

Status
Not open for further replies.

CoolGlenn

Programmer
Nov 6, 2002
10
PH
Is there any function, routine or template on how to get the server date and time? Hope somebody out there could give me an idea on how to solve this problem. I need it very badly. Thank you.
 
Hi,

There is a solution using some Api, but it does not work with Win9x.

First you will need to make a lib for NETApi32.Dll (using libmaker in the bin directory of Clarion.), then add this library to your application (insert module... externalDLL).
Then declare two external Functions in this lib.

NETAPIBufferFree(ULONG),BOOL,PASCAL,RAW
NETRemoteTOD(ULONG ,*ULONG),SIGNED, PASCAL, RAW

you will also need to include in the global map :

Module('kernel32.DLL')
CopyMemory(ULong lpvDest,ULong lpvSource,UnSigned cbCopy),Raw,Pascal,Name('RtlMoveMemory')
End

Then you will need this variable and this group :

TIME_OF_DAY_INFO GROUP
tod_elapsedt ULONG
tod_msecs ULONG
tod_hours ULONG
tod_mins ULONG
tod_secs ULONG
tod_hunds ULONG
tod_timezone ULONG
tod_tinterval ULONG
tod_day ULONG
tod_month ULONG
tod_year ULONG
tod_weekday ULONG
END

TIME_OF_DAY_INFO_PTR ULONG


Now to get the server time use this code :

TIME_OF_DAY_INFO_PTR = Address(TIME_OF_DAY_INFO)
NetRemoteTOD('ServerName', TIME_OF_DAY_INFO_PTR)
CopyMemory(Address(TIME_OF_DAY_INFO),TIME_OF_DAY_INFO_PTR,48)
NETAPIBufferFree(TIME_OF_DAY_INFO_PTR)

The server time will be in the group TIME_OF_DAY_INFO.

Valery.
 
i did follow your instructions but when i run the program nothing happens.. no programs executed
 
hi,

If you give me an email address, i'll send you a C55g application to demonstrate how to do it. You will just need to change the name of the server in the code.

Valery.
 
Here is my email address... glennpa_2002@yahoo.com or glenn.abuzo@filinvestgroup.com.

Again, thank you. Your help is really been a lot for me.
 
I tried again the codes you gave me... its working now! But... the date that it gets is on my pc not on server. I notice this when I change the date on my pc.. I change the date from 7/2/2004 to 7/1/2004 while my server date is 7/2/2004. When I execute the program the date that it gets is 7/1/2004 which is on my pc. Is there any code I should change or add? I also tried changing the code:

NetRemoteTOD('ServerName', TIME_OF_DAY_INFO_PTR)

to

NetRemoteTOD('ECOMDOMAN', TIME_OF_DAY_INFO_PTR)
wherein ECOMDOMAN is a Domain or Server Name

but still dont work...
 
Does anyone know how to capture the System Date and Time of the Server and have it print in a text file?]

AnderSteve
 
Hi,

NETRemoteTOD is not really friendly with clarion apps... but there is other way to do this, you could use NetDDE, this will work with all versions of windows.

1: The server program

Program
Map
Include('DDE.clw')
.
Include('Equates.clw')
LOC:TheServerTime Long
LOC:DDEServerChan Long

Window Window('Time server'),At(,,,),Timer(100)
End

Code
Loc:TheServerTime = Clock()
Open(Window)
0{PROP:Hide} = TRUE
Loc:DDEServerChan = DDESERVER('Net DDE Time Server','TimeServer')
Accept
Case Event()
Of EVENT:Timer
LOC:TheServerTime = Clock()
Yield
Of EVENT:CloseWindow
OrOf EVENT:CloseDown
Break
Of EVENT:DDERequest
Case DDEITEM()
Of 'Time'
DDEWRITE(Loc:DDEServerChan,DDE:Manual,'Time',Loc:TheServerTime)
Of 'Halt'
Break
End
Else
Yield
End
End
DDECLOSE(Loc:DDEServerChan)
Close(Window)

2: The client program

Program
Map
Include('DDE.clw')
End
Include('Equates.clw')
LOC:TheServerTime Long
LOC:DDEClientChan Long
LOC:ServerName String(50)

Window WINDOW('Network DDE Client'),AT(,,275,40),FONT('MS Sans Serif',8,,),SYSTEM,GRAY
PROMPT('The time is:'),AT(6,24),USE(?Loc:TheServerTime:prompt)
STRING(@T04),AT(81,24,,12),USE(Loc:TheServerTime)
BUTTON('Get'),AT(227,2,40,14),USE(?GetTimeButton)
STRING('Server name'),AT(7,7),USE(?String2)
ENTRY(@s20),AT(79,6,60,10),USE(LOC:serverName)
BUTTON('Close'),AT(227,20,40,14),USE(?CloseButton)
END

Code
! if Client is Win9x make sure NetDDE is running
! RUN('c:\windows\netdde.exe')
Loc:ServerName = 'MYSERVER' ! or whatever is the correct server name
Loc:DDEClientChan = DDECLIENT('\\'&CLIP(LOC:ServerName)&'\NDDE$','TimeServer$')

Open(Window)
Accept
Case Event()
Of EVENT:CloseWindow
OrOf EVENT:CloseDown
Break
Else
Yield
End
Case Field()
Of ?GetTimeButton
Case Event()
Of EVENT:Accepted
DDEREAD(Loc:DDEClientChan,DDE:Manual,'Time',Loc:TheServerTime)
End
Of ?CloseButton
Case Event()
Of EVENT:Accepted
Post(EVENT:CloseWindow)
End
End
End
DDECLOSE(Loc:DDEClientChan)
Close(Window)

3:The configuration of NET DDE on the server
(save as .reg and import in the registry of the server)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NetDDE\DDE Shares\TimeServer$]
"ShareName"="TimeServer$"
"OldStyleLink"=""
"NewStyleLink"=""
"StaticDataLink"="Net DDE Time Server|TimeServer"
"ItemList"=hex(7):00,00,00,00
"Revision"=dword:00000001
"ShareType"=dword:00000004
"SharedFlag"=dword:00000001
"Service"=dword:00000001
"StartAppFlag"=dword:00000001
"fuCmdShow"=dword:00000007
"SecurityDescriptor"=hex:01,00,04,80,54,00,00,00,70,00,00,00,00,00,00,00,14,00,\
00,00,02,00,40,00,02,00,00,00,00,00,14,00,3d,02,00,00,01,01,00,00,00,00,00,\
01,00,00,00,00,00,00,24,00,ff,03,0f,00,01,05,00,00,00,00,00,05,15,00,00,00,\
9c,78,de,68,a4,04,26,43,f6,7e,7a,37,10,05,00,00,01,05,00,00,00,00,00,05,15,\
00,00,00,9c,78,de,68,a4,04,26,43,f6,7e,7a,37,10,05,00,00,01,05,00,00,00,00,\
00,05,15,00,00,00,9c,78,de,68,a4,04,26,43,f6,7e,7a,37,01,02,00,00
"NumItems"=dword:00000000
"SerialNumber"=hex:26,00,00,09,00,00,00,01

4:
- import the registry key
- start the server program on the server
- start the client and login...
- get the time

It should not be too difficult to adapt it to your own needs.

If you need the sources, give me your email.

Valéry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top