您可以将文件写入磁盘,然后使用MoveFileEx立即将其标记为"重新启动时删除":
所以在伪代码中:
if(File.Exists(CheckFileName))
return false; // already ran once
else {
// write out the check file
using(checkFile = File.Create(CheckFileName, ...)) {
// and mark it as delete on boot
MoveFileEx(checkFile.SafeHandle,
null,
MOVEFILE_DELAY_UNTIL_REBOOT);
return true; // ok to run
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
239 次 |
| 最近记录: |