Hi skilled,
In my solution I've written the following:
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern unsafe bool CopyFileEx(string lpExistingFileName,
string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData,
Boolean* pbCancel, CopyFileFlags dwCopyFlags);
...
bool result;
unsafe{
result = CopyFileEx(sourceFile, targetFile, null, IntPtr.Zero,
null /* pointer */, 0);
}
if(!result)
Win32Exception exc = new Win32Exception(Marshal.GetLastWin32Error());
// parameter could be omitted according to Win32Exception constructor
// implementation
In the assumption that CopyFileEx was exported with SetLastError = true parameter of DllImport attribute, do I have a chance to get any unhalted exception here?
I'm specifically interested in non-CLR exceptions which are wrapped in RuntimeWrappedException instance. In C++ "throw 1" is a valid construct. So what exceptions should I expect from such P/Invoke calls and where I can obtain such information regarding exceptions (MSDN says nothing regarding exceptions from CopyFileEx)?