3

I use the DeleteFile and CopyFile methods. Do these functions throw exceptions or just set errno and lastError? Do I need to surround this code with try and catch?

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
sofr
  • 5,407
  • 6
  • 28
  • 29
  • These functions are not part of standard C++. We need to know where they're defined before we can say how they behave. – jalf May 16 '09 at 19:22
  • https://stackoverflow.com/questions/51951586/the-copy-task-failed-unexpectedly – Martin Ba Feb 03 '23 at 09:44

2 Answers2

10

If you're referring to the Win32 API functions, the answer is no. No Win32 functions throw, because it is a C API.

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
5

As @jeffamaphone says, they don't throw exceptions because they are C functions.

For errors, they return 0 and set an error code that you can retrieve via GetLastError(). Neither sets errno, because they're Windows APIs.

RichieHindle
  • 272,464
  • 47
  • 358
  • 399