You can call Marshal.GetLastWin32Error() to get the last Windows API error message. This is the suggested method (as opposed to using P/Invoke).
From the docs: "GetLastWin32Error exposes the Win32 GetLastError API method from Kernel32.DLL. This method exists because it is not safe to make a direct platform invoke call to GetLastError to obtain this information. If you want to access this error code, you must call GetLastWin32Error rather than writing your own platform invoke definition for GetLastError and calling it. The common language runtime can make internal calls to APIs that overwrite the operating system maintained GetLastError."
Also, in terms of not modifying source:
This will work in the Visual Studio immediate window, provided the P/Invoke call was decorated with DllImportAttribute.SetLastError. If the P/Invoke call to the windows API was missing that attribute, though, you'll be somewhat out of luck, since it's very possible that the marshalling api will overwrite the value in GetLastError before you could see it.