具体来说,我希望能够读取/写入exe文件本身存储的一些数据.我不需要(或希望)修改可执行代码.
在常规窗口中,我可以使用字符串资源和UpdateResource函数,但在WinCE中不存在.
遗憾的是,CreateFile因文件已被使用而失败.
有人有任何其他建议吗?
解决方法 首先,你为什么需要这样做?您应该可以使用其他方法执行此 *** 作.我对windows-CE并不是特别熟悉,但是如果需要,你可以复制文件,编辑副本,删除第一个,然后运行另一个.这是一种效率低下的方法,但是如果你只需要在程序范围内执行一次或两次并且速度不是问题,我想你可以这样做:
#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 myolD@R_502_6852@.exe"); // Stop the old one running,system("del myolD@R_502_6852@.exe"); // Then delete it. } ifstream myself(argv[0]); // argv[0] is the program itself string fullcode; string line; if (@R_502_6852@.is_open()) { while (@R_502_6852@.good()) { getline(myself,line); line.append("\n"); fullcode.append(line); } } myself.close(); // Do whatever you need to do to the code here. ofstream newcode("myNEW@R_502_6852@.exe"); newcode.write(fullcode); newcode.close(); system("myNEW@R_502_6852@.exe myNEW@R_502_6852@.exe"); // Starts new @R_502_6852@. Also,not a typo.}
祝你的项目好运!
总结以上是内存溢出为你收集整理的c – 修改自身的正在运行的可执行文件全部内容,希望文章能够帮你解决c – 修改自身的正在运行的可执行文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)