mailslot in csharp ?

  • Thread starter Thread starter vertigo
  • Start date Start date
V

vertigo

Hello
Can i use mailslot mechnism in C# ?
I could find API for mailslot only for C/C++ for example:
HANDLE CreateMailslot(
LPCTSTR lpName,
DWORD nMaxMessageSize,
DWORD lReadTimeout,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);

Does it exists any way to create HANDLE, and use CreateMailslot() in C# ?

Thanx
Michal
 
vertigo said:
Hello
Can i use mailslot mechnism in C# ?
I could find API for mailslot only for C/C++ for example:
HANDLE CreateMailslot(
LPCTSTR lpName,
DWORD nMaxMessageSize,
DWORD lReadTimeout,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);

Does it exists any way to create HANDLE, and use CreateMailslot() in C# ?

YOu will have to use PInvoke and call CreateMailslot directly.
HANDLE can be represented by IntPtr quite readily

The C# declaration for CreateMailslot would be something like(untested):
[DllImport("kernel32.dll")]
static extern IntPtr CreateMailslot(string name, int maxMessageSize, int
readTimeout, IntPtr securityAttributes);

I would recomment passing IntPtr.Zero for the attributes unless you know
what you are doing with them.
 
Back
Top