まず、なぜこれを行う必要があるのですか?他の方法でこれを行うことができるはずです。
私は特に Windows-CE に精通しているわけではありませんが、必要に応じて、ファイルをコピーし、コピーを編集し、最初のファイルを削除してから、別のファイルを実行することができます。これは非効率的な方法ですが、プログラムのスパンで 1 回か 2 回実行する必要があり、速度が問題にならない場合は、次のように実行できると思います。
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char * argv[]) {
// Check if this IS the copy:
if (argv[0].find(argv[1]) != string::npos) {
system("taskkill -IM myOLDfile.exe"); // Stop the old one running,
system("del myOLDfile.exe"); // Then delete it.
}
ifstream myself(argv[0]); // argv[0] is the program itself
string fullcode;
string line;
if (file.is_open()) {
while (file.good()) {
getline(myself, line);
line.append("\n");
fullcode.append(line);
}
}
myself.close();
// Do whatever you need to do to the code here.
ofstream newcode("myNEWfile.exe");
newcode.write(fullcode);
newcode.close();
system("myNEWfile.exe myNEWfile.exe"); // Starts new file. Also, not a typo.
}
あなたのプロジェクトで頑張ってください!