public void paint(Graphics g) { g.setFont(fn); g.setColor(Color.blue); g.drawString(counter_str,10,50); }
}
---- CGI 程 序 代 码 如 下:
#include < windows.h > #include < stdio.h >
int SplitArgs (char *str, char *argv[]); int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nShow) { int argc; char *argv[32]; // Max 32 command line arg long num; FILE *fp; argc = SplitArgs(lpszCmdLine, argv); // Split command line args puts("Content-type: text/plain/n"); // NOTE: blank line here if(argc< =1) {printf("!!!Too less Parameter!!!"); printf("/n用法为在counter.exe? 后加上数据文件名"); return(1); } fp=fopen(argv[1],"r"); fscanf(fp,"%ld",&num); num++; printf("/n%ld",num); fclose(fp); fp=fopen(argv[1],"w"); fprintf(fp,"%ld",num); fclose(fp); return(0); }
int SplitArgs (char *str, char *argv[]) { int argc; char *cp; static char safe_copy[256]; // Single threaded, this is OK char appname[256];
GetModuleFileName(NULL, appname, 256); // Get app filename
memset(safe_copy, 0, sizeof(safe_copy)); // Must clear old stuff... strcpy(safe_copy, appname); // VC++ 2.0 strcat(safe_copy, " "); strcat(safe_copy, str);
argc = 0; cp = safe_copy; while (*cp) // Stop at null character { while(*cp && isspace (*cp)) // Scan past white or to end cp += 1; if(*cp) // On next token or at end argv[argc++] = cp; // Next token: ptr and bump while(*cp && !isspace (*cp)) // Scan to white or end cp += 1; *cp++ = '/0'; // Terminate this token } return (argc); }