Гонял на WNT4SrvSP6(ENG)/W2KAdvSrvSP3(ENG), Client 4.80(ENG), NW411SP9(ENG).
Права админские. На мастдайках'95 и махарайках'98 пойдёт вряд ли.
- Код: Выделить всё
// (#) 2009 by Charles Kludge
#include <windows.h>
#include <winbase.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "nwcalls.h"
#include "nwclxcon.h"
#include "nwdstype.h"
#include "nwdsmisc.h"
#include <dos.h>
char *pSrv = NULL;
NWCONN_HANDLE connh = 0;
void chkerr(NWDSCCODE c, pnstr err) {
if ((c) && (c!=-659)) {
printf("Error %s code = %d\n\r", err, c);
printf("exiting !\n\r");
if(pSrv) free(pSrv);
if(connh) NWCCCloseConn(connh);
exit(-1);
}
}
void main(int argc, char* argv[], char *env[])
{
DWORD tm_ =0;
struct tm tmbuf;
struct dostime_t dtm;
struct dosdate_t ddt;
char buf[30];
chkerr(NWCallsInit(NULL, NULL),"NWCallsInit");
chkerr(NWCLXInit(NULL, NULL),"NWCLXInit");
if(argc <2) {
pSrv = malloc(0x80);
bzero(pSrv,0x80);
chkerr(NWCCGetPrefServerName(0x80,pSrv),"NWCCGetPrefServerName");
}
else pSrv = argv[1];
chkerr(NWCCOpenConnByName(NULL,pSrv,NWCC_NAME_FORMAT_BIND,NWCC_OPEN_LICENSED,NWCC_TRAN_TYPE_WILD,&connh),"NWCCOpenConnByName");
chkerr(NWGetFileServerUTCTime(connh,&tm_),"NWGetFileServerUTCTime");
_localtime(&tm_,&tmbuf);
dtm.hour = tmbuf.tm_hour;
dtm.minute = tmbuf.tm_min;
dtm.second = tmbuf.tm_sec;
dtm.hsecond = 0;
chkerr(_dos_settime(&dtm), "_dos_settime");
ddt.day = tmbuf.tm_mday;
ddt.month = tmbuf.tm_mon+1;
ddt.year = tmbuf.tm_year+1900;
ddt.dayofweek = tmbuf.tm_wday;
chkerr(_dos_setdate(&ddt), "_dos_setdate");
tm_ = time(NULL);
strftime(&buf,30,"%x %X",localtime(&tm_));
printf("Server %s, time %s\n\r",pSrv,buf);
chkerr(NWCCCloseConn(connh),"NWCCCloseConn");
};
P.S. Желающие получить .exe(21k) - в мыло.