This would seem a better place to use ExitWithLastError() (which does everything you need without needing to explicitly declare the DWORD).