//*************************************************************** // From the book "Win32 System Services: The Heart of Windows 98 // and Windows 2000" // by Marshall Brain // Published by Prentice Hall // // Copyright 1995, by Prentice Hall. // // This code implements the "ran" portion of ranmon. //*************************************************************** // ran.cpp // Usage: ran #include #include #include #include #include #include #include "ran.h" #define MAX_USERNAME 15 int main(int argc, char *argv[]) { HANDLE RANSlot; BOOL Status; DWORD NumBytesWritten; DWORD length; RANData randata; char cmdLine[MAX_PATH]; char slotPath[MAX_PATH]; char userName[MAX_USERNAME + 1]; int i; long elapsedTime; time_t startTime; time_t stopTime; char *timeString; if (argc < 2) { cout << "Usage: ran \n" << endl; return(1); } /* If -stopmon, stop ranmon */ if (!strcmp(argv[1], "-stopmon")) { randata.stopMonitors=1; cout << "Sending Ranmon the stop signal..." << endl; } /* otherwise, run the requested program */ else { /* Get the comp name and record it */ randata.stopMonitors=0; strcpy(randata.AppName, argv[1]); length=sizeof(randata.WkstnName); GetComputerName(randata.WkstnName, &length); strcpy(cmdLine, argv[1]); for (i=2; i