سؤال

What exactly does this exception mean, and why it is happening?

More info:

This is where it happens:

Id = GlobalAddAtom("aString");

if (Marshal.GetLastWin32Error() != 0)
{ throw new Win32Exception(); }

I know that GlobalAddAtom is indeed in kernel32.dll (that's where I'm DllImporting it from).

هل كانت مفيدة؟

المحلول

GetLastError returns the last error that any API function triggered.

Check that the returned Id value is zero - only in that case did GlobalAddAtom fail.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top