SpringCard LibCs.Windows for .NET  18.10.10
A set of utilities for the Windows platform
SpringCard.LibCs.Windows.MailSlotServer.MailSlot Class Reference

The class exposes Windows APIs to be used in this code sample. More...

Public Member Functions

static SafeMailslotHandle CreateMailslot (string mailslotName, uint nMaxMessageSize, int lReadTimeout, SECURITY_ATTRIBUTES securityAttributes)
 Creates an instance of a mailslot and returns a handle for subsequent operations. More...
 
static SafeMailslotHandle CreateFile (string fileName, FileDesiredAccess desiredAccess, FileShareMode shareMode, IntPtr securityAttributes, FileCreationDisposition creationDisposition, int flagsAndAttributes, IntPtr hTemplateFile)
 Creates or opens a file, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe. More...
 
static bool GetMailslotInfo (SafeMailslotHandle hMailslot, IntPtr lpMaxMessageSize, out int lpNextSize, out int lpMessageCount, IntPtr lpReadTimeout)
 Retrieves information about the specified mailslot. More...
 
static bool ReadFile (SafeMailslotHandle handle, byte[] bytes, int numBytesToRead, out int numBytesRead, IntPtr overlapped)
 Reads data from the specified file or input/output (I/O) device. More...
 
static bool WriteFile (SafeMailslotHandle handle, byte[] bytes, int numBytesToWrite, out int numBytesWritten, IntPtr overlapped)
 Writes data to the specified file or input/output (I/O) device. More...
 
static bool ConvertStringSecurityDescriptorToSecurityDescriptor (string sddlSecurityDescriptor, int sddlRevision, out SafeLocalMemHandle pSecurityDescriptor, IntPtr securityDescriptorSize)
 The ConvertStringSecurityDescriptorToSecurityDescriptor function converts a string-format security descriptor into a valid, functional security descriptor. More...
 
static bool CloseHandle (SafeMailslotHandle handle)
 

Detailed Description

The class exposes Windows APIs to be used in this code sample.

Member Function Documentation

◆ ConvertStringSecurityDescriptorToSecurityDescriptor()

static bool SpringCard.LibCs.Windows.MailSlotServer.MailSlot.ConvertStringSecurityDescriptorToSecurityDescriptor ( string  sddlSecurityDescriptor,
int  sddlRevision,
out SafeLocalMemHandle  pSecurityDescriptor,
IntPtr  securityDescriptorSize 
)

The ConvertStringSecurityDescriptorToSecurityDescriptor function converts a string-format security descriptor into a valid, functional security descriptor.

Parameters
sddlSecurityDescriptorA string containing the string-format security descriptor (SDDL) to convert.
sddlRevisionThe revision level of the sddlSecurityDescriptor string. Currently this value must be 1.
pSecurityDescriptorA pointer to a variable that receives a pointer to the converted security descriptor.
securityDescriptorSizeA pointer to a variable that receives the size, in bytes, of the converted security descriptor. This parameter can be IntPtr.Zero.
Returns
If the function succeeds, the return value is true.

◆ CreateFile()

static SafeMailslotHandle SpringCard.LibCs.Windows.MailSlotServer.MailSlot.CreateFile ( string  fileName,
FileDesiredAccess  desiredAccess,
FileShareMode  shareMode,
IntPtr  securityAttributes,
FileCreationDisposition  creationDisposition,
int  flagsAndAttributes,
IntPtr  hTemplateFile 
)

Creates or opens a file, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe.

Parameters
fileNameThe name of the file or device to be created or opened.
desiredAccessThe requested access to the file or device, which can be summarized as read, write, both or neither (zero).
shareModeThe requested sharing mode of the file or device, which can be read, write, both, delete, all of these, or none (refer to the following table).
securityAttributesA SECURITY_ATTRIBUTES object that contains two separate but related data members: an optional security descriptor, and a Boolean value that determines whether the returned handle can be inherited by child processes.
creationDispositionAn action to take on a file or device that exists or does not exist.
flagsAndAttributesThe file or device attributes and flags.
hTemplateFileHandle to a template file.
Returns
If the function succeeds, the return value is an open handle to the specified file, device, named pipe, or mail slot. If the function fails, the return value is an invalid handle.

◆ CreateMailslot()

static SafeMailslotHandle SpringCard.LibCs.Windows.MailSlotServer.MailSlot.CreateMailslot ( string  mailslotName,
uint  nMaxMessageSize,
int  lReadTimeout,
SECURITY_ATTRIBUTES  securityAttributes 
)

Creates an instance of a mailslot and returns a handle for subsequent operations.

Parameters
mailslotNameMailslot name
nMaxMessageSizeThe maximum size of a single message
lReadTimeoutThe time a read operation can wait for a message.
securityAttributesSecurity attributes
Returns
If the function succeeds, the return value is a handle to the server end of a mailslot instance.

◆ GetMailslotInfo()

static bool SpringCard.LibCs.Windows.MailSlotServer.MailSlot.GetMailslotInfo ( SafeMailslotHandle  hMailslot,
IntPtr  lpMaxMessageSize,
out int  lpNextSize,
out int  lpMessageCount,
IntPtr  lpReadTimeout 
)

Retrieves information about the specified mailslot.

Parameters
hMailslotA handle to a mailslot
lpMaxMessageSizeThe maximum message size, in bytes, allowed for this mailslot.
lpNextSizeThe size of the next message in bytes.
lpMessageCountThe total number of messages waiting to be read.
lpReadTimeoutThe amount of time, in milliseconds, a read operation can wait for a message to be written to the mailslot before a time-out occurs.
Returns

◆ ReadFile()

static bool SpringCard.LibCs.Windows.MailSlotServer.MailSlot.ReadFile ( SafeMailslotHandle  handle,
byte []  bytes,
int  numBytesToRead,
out int  numBytesRead,
IntPtr  overlapped 
)

Reads data from the specified file or input/output (I/O) device.

Parameters
handleA handle to the device (for example, a file, file stream, physical disk, volume, console buffer, tape drive, socket, communications resource, mailslot, or pipe).
bytesA buffer that receives the data read from a file or device.
numBytesToReadThe maximum number of bytes to be read.
numBytesReadThe number of bytes read when using a synchronous IO.
overlappedA pointer to an OVERLAPPED structure if the file was opened with FILE_FLAG_OVERLAPPED.
Returns
If the function succeeds, the return value is true. If the function fails, or is completing asynchronously, the return value is false.

◆ WriteFile()

static bool SpringCard.LibCs.Windows.MailSlotServer.MailSlot.WriteFile ( SafeMailslotHandle  handle,
byte []  bytes,
int  numBytesToWrite,
out int  numBytesWritten,
IntPtr  overlapped 
)

Writes data to the specified file or input/output (I/O) device.

Parameters
handleA handle to the file or I/O device (for example, a file, file stream, physical disk, volume, console buffer, tape drive, socket, communications resource, mailslot, or pipe).
bytesA buffer containing the data to be written to the file or device.
numBytesToWriteThe number of bytes to be written to the file or device.
numBytesWrittenThe number of bytes written when using a synchronous IO.
overlappedA pointer to an OVERLAPPED structure is required if the file was opened with FILE_FLAG_OVERLAPPED.
Returns
If the function succeeds, the return value is true. If the function fails, or is completing asynchronously, the return value is false.

The documentation for this class was generated from the following file: