Windows Service - file writing.
I'm currently putting an application I have created into a windows service. I have a problem where ofstream does not appear to be working in my test service application. In this code example below, when I run from the services window, the FILE method writes to file but the ofstream does not although both work when run from VC++. Any help with this issue would be much apprecated.
if(logging){
char* logNote = new char[1000];
TimeAndDate sysTime;
sysTime.GetScreenTimeWithSeconds(logNote);
strcat(logNote," - ");
strcat(logNote,logInfo);
strcat(logNote,"\n");
//findlogfilename
char* logFileName = new char[500];
char* logDate = new char[500];
sysTime.GetDate(logDate);
strcpy(logFileName,"RssServerLog");
strcat(logFileName,logDate);
strcat(logFileName,".dat");
//open file where seek set at end,app - ignores any further seek command
fstream logFile;
logFile.open(logFileName, ios::app);
logFile << logNote;
logFile.close();
logFile.clear();
FILE* log;
log = fopen("C:\\memstatus2.txt", "a+");
//if (log == NULL)
//return -1;
fprintf(log, "%s\n", logNote);
fclose(log);
}
Who is the service run as and can it interact with desktop? The stream may require a desktop environment though I do not know for certain.
Hi.
I've got it running under local system account with desktop access active so that i can debug it.
thanks for the reply
I've got it running under local system account with desktop access active so that i can debug it.
thanks for the reply
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement