public static String PtrToStringAuto(IntPtr ptr) { if (Win32Native.NULL == ptr) { return(null); } else if (IsWin32Atom(ptr)) { return(null); } else { int nc = Win32Native.lstrlen(ptr); StringBuilder sb = new StringBuilder(nc); Win32Native.lstrcpy(sb, ptr); return(sb.ToString()); } }