MoveFileEx 带 MOVEFILE_DELAY_UNTIL_REBOOT参数,如何知道重新启动后替换成功与否?

解决方案 »

  1.   

    比较时间戳。
    看MSDN。
      

  2.   

    也可以看注册表
    http://support.microsoft.com/kb/202071/zh-cn
      

  3.   

    只想知道是不是被替换了用GetFileTime()比较最后写时间就可以了,不要要把前一个时间保存一下
    如果说要知道替换了,而且也对了,感觉有点钻牛角尖,毕竟我们粘贴的时候也不会怀疑只粘了一半过来
      

  4.   

    MSDN上有说明的,HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations,修改了这个价值,你只要判断注册表值的改变来判断了。
    具体看看MSDN。
      

  5.   

    If the dwFlags parameter specifies MOVEFILE_DELAY_UNTIL_REBOOT, MoveFileEx fails if it cannot access the registry. The function stores the locations of the files to be renamed at restart in the following registry value:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
    This registry value is of type REG_MULTI_SZ. Each rename operation stores the following pair of NULL-terminated strings: 
    szDstFile\0\0
    szSrcFile\0szDstFile\0\0
    The system uses these registry entries to complete the operations at restart in the same order that they were issued. For example, the following code fragment creates registry entries that delete szDstFile and rename szSrcFile to be szDstFile at restart: [C++]MoveFileEx(szDstFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
    MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
      

  6.   

    把第2个参数改成放到C:\Documents and Settings\Administrator\「开始」菜单\程序\启动
    开机就能...