看看这个对你是否有帮助?
声明如下:
[DllImport("kernel32.dll", SetLastError=true)] static extern int CreateMailslotA ( string lpName, int nMaxMessageSize, int lReadTimeout, ref SECURITY_ATTRIBUTES lpSecurityAttributes)
struct SECURITY_ATTRIBUTES{
int nLength;
int lpSecurityDescriptor;
int bInheritHandle;
}
声明如下:
[DllImport("kernel32.dll", SetLastError=true)] static extern int CreateMailslotA ( string lpName, int nMaxMessageSize, int lReadTimeout, ref SECURITY_ATTRIBUTES lpSecurityAttributes)
struct SECURITY_ATTRIBUTES{
int nLength;
int lpSecurityDescriptor;
int bInheritHandle;
}
aa = null;CreateMailslot(m_strSlotName, 10000, 400, aa );
LPSECURITY_ATTRIBUTES xxx=new LPSECURITY_ATTRIBUTES();
然后用这个去调用函数啊:
CreateMailslot(m_strSlotName, 10000, 400, xxx);
m_strSlotName = @"\\\\.\\mailslot\\XDLGT"; LPSECURITY_ATTRIBUTES lpSa = new LPSECURITY_ATTRIBUTES();
lpSa.nLength = 0;
lpSa.bInheritHandle = false;
lpSa.lpSecurityDescriptor = 0; m_hSlot = CreateMailslot(m_strSlotName, 10000, 400, lpSa);
if (m_hSlot.ToInt32()<=0)
AddErr("未能成功创建邮槽");
public struct SECURITY_ATTRIBUTES
{
public int nLength;
public int lpSecurityDescriptor;
public int bInheritHandle;
};[DllImport("kernel32.dll", SetLastError=true)]
static extern int CreateMailslotA ( string lpName, int nMaxMessageSize, int lReadTimeout, ref SECURITY_ATTRIBUTES lpSecurityAttributes); 调用如下
string m_strSlotName = "\\\\.\\mailslot\\XDLGT";
SECURITY_ATTRIBUTES lpSa = new SECURITY_ATTRIBUTES();
lpSa.nLength = 0;
lpSa.bInheritHandle = 0;
lpSa.lpSecurityDescriptor = 0;int m_hSlot = CreateMailslotA(m_strSlotName, 10000, 400, ref lpSa);