使用CreateRectory()捕获error_already_exists和类似的错误

Catching ERROR_ALREADY_EXISTS and similar errors with CreateDirectory()

本文关键字:错误 exists already 捕获 error 使用 CreateRectory      更新时间:2023-10-16

我希望使用CreateRectory(),RemoveRectory()和类似功能制作程序。这些命令中可能的返回错误之一error_already_exists。我想要一个IF语句来捕获此错误并在屏幕上发布消息并继续。

您需要调用GetLastError ()并检查错误条件是否符合ERROR_ALREADY_EXISTS;调用CreateDirectory()并返回0。