发布于 2003-05-15 10:07:33
0楼
这是记录用户登陆和登出时间的源码,用户信息放在C:\Wincclog.txt文件当中:
#include "apdefap.h"
int gscAction( void )
{
char* username, buf[128];
static char preuser[128];
FILE *fp;
username = GetTagChar("@CurrentUser");
if (strcmp(username,preuser) != 0)
{
fp= fopen("c:\wincclog.txt", "a+");
if(strcmp(username, "") != 0)
{
if(strcmp(preuser, "") != 0)
{
SetTagChar("previous",preuser);
SetTagChar("timelogout1",GetLocalTimeString());
sprintf(buf, "%s Logout at %s\n", preuser, GetLocalTimeString());
fputs(buf, fp);
}
SetTagChar("user1",username);
SetTagChar("timelogin1",GetLocalTimeString());
sprintf(buf, "%s Login at %s\n", username, GetLocalTimeString());
fputs(buf, fp);
}else
{
SetTagChar("user1",username);
SetTagChar("previous",preuser);
SetTagChar("timelogout1",GetLocalTimeString());
sprintf(buf, "%s Logout at %s\n", preuser, GetLocalTimeString());
fputs(buf, fp);
}
strcpy(preuser, username);
fclose(fp);
}
return 0;
}