to get the error code from the WinAPI call use the Marshal.GetLastWin32Error(); Also remember to decorate your call with "Set Last Error = true";
Here is an example i have for calling a popup on a taskbar icon :
[DllImport("shell32.dll",SetLastError=true)]
public static extern bool Shell_NotifyIcon(uint dwMessage, [In] ref NotifyIconData pnid);
usage:
//call your code like you usually call the method
bool callResult = Caller.Shell_NotifyIcon((uint)NotifyIconMessage.NIM_ADD, ref n);
//afther that call the GetLastError to get the error code
int errorCode = Marshal.GetLastWin32Error();
google the error code and see what it means