Solved

TAPI APIs failing

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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