Solved

TAPI APIs failing

Posted on 1997-04-07
2
312 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 100 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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