Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TAPI APIs failing

Posted on 1997-04-07
2
Medium Priority
?
336 Views
Last Modified: 2013-12-03
I am trying to use TAPI 2.0 with I/O completion ports. The following code returns LINEERR_OPERATIONUNAVAIL

DWORD dwNumDevices = 0;
DWORD dwAPIVersion = TAPI_CURRENT_VERSION;
LINEINITIALIZEEXPARAMS parms;
parms.dwTotalSize = sizeof(LINEINITIALIZEEXPARAMS);
parms.dwOptions = LINEINITIALIZEEXOPTION_USECOMPLETIONPORT;
parms.dwCompletionKey = 1;
parms.Handles.hCompletionPort = comp;

long rc = lineInitializeEx(&myLineApp,
                     GetModuleHandle(0),
                     0,
                     0,
                     &dwNumDevices,
                     &dwAPIVersion,
                       &parms);

I can successfully use lineInialize, but I'd much rather use   I/O completion ports or event handles than the hidden window method of event notification.

Bill Weston

0
Comment
Question by:Bill Weston
2 Comments
 

Author Comment

by:Bill Weston
ID: 1334459
Edited text of question
0
 
LVL 1

Accepted Solution

by:
edtmihu earned 300 total points
ID: 1334460
I tried this:
HANDLE hFile = CreateFile( _T( "C:\\T.T" ), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_FLAG_OVERLAPPED, NULL );

HANDLE comp = ::CreateIoCompletionPort ( hFile, NULL, 1, 0 );
LINEINITIALIZEEXPARAMS lip;
::ZeroMemory( &lip, sizeof( lip ) );
lip.dwTotalSize = sizeof( lip );
lip.dwOptions = LINEINITIALIZEEXOPTION_USECOMPLETIONPORT;
lip.dwCompletionKey = 1;
lip.Handles.hCompletionPort = comp;
pTapi->hLineApp = 0;
pTapi->dwNumDevs = 0;
pTapi->dwAPIVersion = 0x00020000;

LONG err = ::lineInitializeEx( &pTapi->hLineApp, AfxGetApp()->m_hInstance, 0, AfxGetApp()->m_pszAppName, &pTapi->dwNumDevs, &pTapi->dwAPIVersion, &lip );

This worked for me. I'm using VC++ 4.2b. I have UNICODE defined.
I only checked the return value from ::lineInitializeEx(...), nothing more.

I use events myself. Like this:
LINEINITIALIZEEXPARAMS lip;
::ZeroMemory( &lip, sizeof( lip ) );
lip.dwTotalSize = sizeof( lip );
lip.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT;
pTapi->hLineApp = 0;
pTapi->dwNumDevs = 0;
pTapi->dwAPIVersion = 0x00020000;

LONG err = ::lineInitializeEx( &pTapi->hLineApp, AfxGetApp()->m_hInstance, 0, AfxGetApp()->m_pszAppName, &pTapi->dwNumDevs, &pTapi->dwAPIVersion, &lip );
.
Check err
.
open line devices and stuff
.
while ( 1 )
 {
 DWORD dwEvent = WaitForMultipleObjects( 2, pTapi->hEvents, FALSE, INFINITE );
}
etc.
Works great.
Hope this helped

Regards/Michael
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question