Show / Hide Table of Contents

Method WndCopyData.SendReceive(+ 2 overloads)


Overload

Sends string or other data to a window of any process. Uses API SendMessageWM_COPYDATA. Receives string or other data returned by that window with WndCopyData.Return.

public static bool SendReceive<TSend, TReceive>(wnd w, int dataId, ReadOnlySpan<TSend> send, WndCopyData.ResultReader<TReceive> receive) where TSend : unmanaged where TReceive : unmanaged
Parameters
w  (wnd)

The window.

dataId  (int)

Data id. It is COPYDATASTRUCT.dwData.

send  (ReadOnlySpan<TSend>)

Data to send. For example string or byte[]. String can contain '\0' characters.

receive  (WndCopyData.ResultReader<TReceive>)

Callback function that can convert the received data to desired format.

Returns
bool

false if failed.

Type Parameters
TSend

Type of data elements. For example, char for string, byte for byte[]

TReceive

Type of received data elements. For example, char for string, byte for byte[].


Overload(next)

Calls SendReceive<TSend, TReceive>(wnd, int, ReadOnlySpan<TSend>, ResultReader<TReceive>) and gets the received data as byte[].

public static bool SendReceive<TSend>(wnd w, int dataId, ReadOnlySpan<TSend> send, out byte[] received) where TSend : unmanaged
Parameters
w  (wnd)

The window.

dataId  (int)

Data id. It is COPYDATASTRUCT.dwData.

send  (ReadOnlySpan<TSend>)

Data to send. For example string or byte[]. String can contain '\0' characters.

received  (byte[])

The received data.

Returns
bool

false if failed.

Type Parameters
TSend

Type of data elements. For example, char for string, byte for byte[]


Overload(top)

Calls SendReceive<TSend, TReceive>(wnd, int, ReadOnlySpan<TSend>, ResultReader<TReceive>) and gets the received string.

public static bool SendReceive<TSend>(wnd w, int dataId, ReadOnlySpan<TSend> send, out string received) where TSend : unmanaged
Parameters
w  (wnd)

The window.

dataId  (int)

Data id. It is COPYDATASTRUCT.dwData.

send  (ReadOnlySpan<TSend>)

Data to send. For example string or byte[]. String can contain '\0' characters.

received  (string)

The received data.

Returns
bool

false if failed.

Type Parameters
TSend

Type of data elements. For example, char for string, byte for byte[]