lineInitializeEx
The lineInitializeEx
function initializes the application's use of TAPI for subsequent use of the
line abstraction. It registers the application's specified notification
mechanism and returns the number of line devices available to the application.
A line device is any device that provides an implementation for the
line-prefixed functions in the Telephony API.
LONG lineInitializeEx(
LPHLINEAPP lphLineApp, |
|
HINSTANCE hInstance, |
|
LINECALLBACK lpfnCallback, |
|
LPCSTR lpszFriendlyAppName, |
|
LPDWORD lpdwNumDevs, |
|
LPDWORD lpdwAPIVersion, |
|
LPLINEINITIALIZEEXPARAMS lpLineInitializeExParams |
|
); |
|
Parameters
lphLineApp
A pointer to
a location that is filled with the application's usage handle for TAPI.
hInstance
The instance
handle of the client application or DLL. The application or DLL may pass NULL
for this parameter, in which case TAPI will use the module handle of the root
executable of the process (for purposes of identifying call handoff targets and
media mode priorities).
lpfnCallback
The address
of a callback function that is invoked to determine status and events on the
line device, addresses, or calls, when the application is using the
"hidden window" method of event notification (for more information
see lineCallbackFunc
lpszFriendlyAppName
A pointer to
a NULL-terminated ASCII string that contains only displayable ASCII characters.
If this parameter is not NULL, it contains an application-supplied name of the
application. This name is provided in the LINECALLINFO
lpdwNumDevs
A pointer to
a DWORD-sized location. Upon successful completion of this request, this
location is filled with the number of line devices available to the application.
lpdwAPIVersion
A pointer to
a DWORD-sized location. The application must initialize this DWORD, before
calling this function, to the highest API version it is designed to support
(for example, the same value it would pass into dwAPIHighVersion
parameter of lineNegotiateAPIVersion
lpLineInitializeExParams
A pointer to
a structure of type LINEINITIALIZEEXPARAMS
Return Values
Returns zero
if the request is successful or a negative error number if an error has
occurred. Possible return values are:
LINEERR_INVALAPPNAME,
LINEERR_OPERATIONFAILED, LINEERR_INIFILECORRUPT, LINEERR_INVALPOINTER,
LINEERR_REINIT, LINEERR_NOMEM, LINEERR_INVALPARAM.
Remarks
Applications
must select one of three mechanisms by which TAPI notifies the application of
telephony events: Hidden Window, Event Handle, or Completion Port.
The Hidden
Window mechanism is selected by specifying
LINEINITIALIZEEXOPTION_USEHIDDENWINDOW in the dwOptions field in the LINEINITIALIZEEXPARAMS
The Event
Handle mechanism is selected by specifying LINEINITIALIZEEXOPTION_USEEVENT in
the dwOptions field in the LINEINITIALIZEEXPARAMS structure. In
this mechanism, TAPI creates an event object on behalf of the application, and
returns a handle to the object in the hEvent field in LINEINITIALIZEEXPARAMS
The
Completion Port mechanism is selected by specifying
LINEINITIALIZEEXOPTION_USECOMPLETION PORT in the dwOptions field in the LINEINITIALIZEEXPARAMS
structure. In this mechanism, whenever a telephony event needs to be sent to
the application, TAPI will send it to the application using PostQueuedCompletionStatus
to the completion port that the application specified in the hCompletionPort
field in LINEINITIALIZEEXPARAMS, tagged with the completion key that the
application specified in the dwCompletionKey field in LINEINITIALIZEEXPARAMS.
The application must have previously created the completion port using CreateIoCompletionPort.
The application retrieves events using GetQueuedCompletionStatus. Upon
return from GetQueuedCompletionStatus, the application will have the
specified dwCompletionKey written to the DWORD pointed to by the lpCompletionKey
parameter, and a pointer to a LINEMESSAGE
When a multi-threaded
application is using the Event Handle mechanism and more than one thread is
waiting on the handle, or the Completion Port notification mechanism and more
than one thread is waiting on the port, it is possible for telephony events to
be processed out of sequence. This is not due to the sequence of delivery of
events from TAPI, but would be caused by the time slicing of threads or the
execution of threads on separate processors.
If
LINEERR_REINIT is returned and TAPI reinitialization has been requested, for
example as a result of adding or removing a Telephony service provider, then lineInitializeEx
requests are rejected with this error until the last application shuts down its
usage of the API (using lineShutdown), at which time the new configuration
becomes effective and applications are once again permitted to call lineInitializeEx.
If the
LINEERR_INVALPARAM error value is returned, the specified hInstance
parameter is invalid.
The
application can refer to individual line devices by using line device IDs that
range from zero to dwNumDevs minus one. An application should not assume
that these line devices are capable of any particular TAPI function without
first querying their device capabilities by lineGetDevCaps and lineGetAddressCaps.
See Also