How would you run a file through C++ code? And after done loading a file, how do you close the window that C++ is using?

Is this even possible?