beautypg.com

Mcpopen, Parameters, Return value – MagTek MAGTEK User Manual

Page 63: Remarks

background image

Section 5. Application Programmable Interface


57

McpOpen

This function is used to open the communication channel and establish communications with an
MCP device. Use McpClose to close the channel.


DWORD McpOpen( LPSTR lpDeviceName, PHANDLE hpDevice );

Parameters

lpDeviceName


Pointer to a null terminated string which specifies the logical device name of the MCP device to
which communications is to be established. This name could be a hard coded device name, a
name obtained from the registry, or other configuration data, or more likely, a name returned
from the McpEnum function.

hpDevice


Pointer to storage area to receive the open handle to the specified device (communications
resource). This handle is used on subsequent calls to functions requiring communications with
the MCP device. If the function fails, the value of hpDevice is not modified.

Return Value

The returned value indicates the outcome of the open function.

Value

Meaning

MCP_ST_OK

Success. The channel has been established.

MCP_ST_NOT_FOUND

Unknown device or device not found

MCP_ST_ACCESS_DENI
ED

Device is already open

MCP_ST_BAD_ACCESS

lpDeviceName or hpDevice parameter is an invalid pointer

MCP_ST_FAILED Other

error

Remarks

The host application uses McpOpen to open a handle to a communications resource.
If the specified resource is currently being used, this function fails. Any thread of the process can
use the handle returned by McpOpen to identify the resource in any of the functions that access
the resource.

Some devices automatically synchronize to communication parameters used by the host. For
example, some serial devices automatically synchronize to the baud rate the host is using. This
synchronization occurs during the call to McpOpen. Once a device is synchronized, it will not