Hey everyone,
I'm trying to write a function that finds the default Program Files directory. I've created one that write the directory to a file, then it gets opened for reading, but this is extremely unproductive and I was wondering if there is a way around this:
I'm trying to avoid the use of the system() command...Code:string PgmFilesDir() { system("echo %PROGRAMFILES%>pgmfiles.txt"); ifstream f ("pgmfiles.txt"); if ( !f.is_open() ) { cout << "ERROR! Unable to locate program files directory!" << endl << "Press a key to quit."; system("pause>nul"); ExitProcess(0); } string pgmfiles; getline(f, pgmfiles, '\n'); return pgmfiles; }
Any help will be greatly appreciated.
Thanks,
Matt



LinkBack URL
About LinkBacks


