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.
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
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.
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
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
LOCDEServerChan Long
Window Window('Time server'),At(,,,),Timer(100)
End
Code
Loc:TheServerTime = Clock()
Open(Window)
0{PROP:Hide} = TRUE
LocDEServerChan = DDESERVER('Net DDE Time Server','TimeServer')
Accept
Case Event()
Of EVENT:Timer
LOC:TheServerTime = Clock()
Yield
Of EVENT:CloseWindow
OrOf EVENT:CloseDown
Break
Of EVENTDERequest
Case DDEITEM()
Of 'Time'
DDEWRITE(LocDEServerChan,DDE:Manual,'Time',Loc:TheServerTime)
Of 'Halt'
Break
End
Else
Yield
End
End
DDECLOSE(LocDEServerChan)
Close(Window)
2: The client program
Program
Map
Include('DDE.clw')
End
Include('Equates.clw')
LOC:TheServerTime Long
LOCDEClientChan 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:TheServerTimerompt)
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
LocDEClientChan = 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(LocDEClientChan,DDE:Manual,'Time',Loc:TheServerTime)
End
Of ?CloseButton
Case Event()
Of EVENT:Accepted
Post(EVENT:CloseWindow)
End
End
End
DDECLOSE(LocDEClientChan)
Close(Window)
3:The configuration of NET DDE on the server
(save as .reg and import in the registry of the server)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.