Solved

TAPI APIs failing

Posted on 1997-04-07
2
308 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
Comment Utility
Edited text of question
0
 
LVL 1

Accepted Solution

by:
edtmihu earned 100 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now