HI Team,
First of all, I'm new to C++, so my knowlege is like 2% and I would like to thank you for any help provided. Well I'm working on a project that looks like this:
-- I'm creating an executalble (EXE) that will monitor and create a file into C:/program files/GMLocal7/ directory if it doesn't exist.
-- If the file gets deleted by user or another program, I want my exe to re-create it.
-- My EXE needs be running in the background w/o user interaction.
so far my current exe is creating the file but locks it so, when I try to delete the file Windows is telling me that the file is begin used by another program.
Note: I don't want my EXE to delete the file..... The USER will be deleting this file.
Does anyone know what needs to be added to the code in order for EXE not to lock the file its generating?
here's the code I'm using to compile my small app:
#include "stdafx.h"
#include "windows.h"
#include "iostream"
#include "fstream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE ); // hide the console window
while( true )
{
fstream file;
file.open( "C:/Program Files/GMLocal7/.g0ldm1n3", ios::in );
if( file.is_open() == false )
{
file.open( "C:/Program Files/GMLocal7/.g0ldm1n3", ios::out );
}
Sleep( 10000 ); // Sleep for 10 secs
}
return 0;
}
thanks in advance for your help!