[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool CloseHandle(IntPtr handle); [DllImport("kernel32", EntryPoint = "GetLastError")]
public static extern int GetLastError();
CloseHandle()释放两次就会抛异常,用GetLastError()来捕获,如果返回3,〖3〗-系统找不到指定的路径。
解决办法:
CloseHandle(m_hSharedMemoryFile);
m_hSharedMemoryFile = IntPtr.Zero;