I ask this because I protected my app with sysdate but the user can easy change the sys date and lunch the app
If I have the date od Internet I can change the sysdate od pc ...and then my app
On forum I tried this source of Antonio Linares
- Code: Select all Expand view RUN
- // Internet time
#include "FiveWin.ch"
function Main()
MsgInfo( GetNtpDate( "204.123.2.72" ) )
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <winsock.h>
#include <time.h>
#define MAXLEN 1024
HB_FUNC( GETNTPDATE )
{
char * hostname = ( char * ) hb_parc( 1 );
unsigned char msg[ 48 ] = { 010, 0, 0, 0, 0, 0, 0, 0, 0 }; // the packet we send
unsigned long buf[ MAXLEN ]; // the buffer we get back
struct sockaddr_in server_addr;
int s; // socket
WSADATA wsa;
struct timeval timeout;
fd_set fds;
time_t tmit;
WSAStartup( 0x101, &wsa );
s = socket( PF_INET, SOCK_DGRAM, getprotobyname( "udp" )->p_proto );
memset( &server_addr, 0, sizeof( server_addr ) );
server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = inet_addr( hostname );
server_addr.sin_port = htons( 123 ); // ntp port
sendto( s, msg, sizeof( msg ), 0, ( struct sockaddr * ) &server_addr, sizeof( server_addr ) );
FD_ZERO( &fds );
FD_SET( s, &fds );
timeout.tv_sec = 10;
timeout.tv_usec = 0;
if( select( 0, &fds, NULL, NULL, &timeout ) )
{
recv( s, ( void * ) buf, sizeof( buf ), 0 );
tmit = ntohl( buf[ 10 ] );
tmit-= 2208988800U;
}
else
MessageBox( 0, "can't read from NTP server", "ok", 0 );
WSACleanup();
hb_retc( ctime( &tmit ) );
}
#pragma ENDDUMP
but it return allways can't read from NTP server any solution ?