Problem using this function to fill LINEDEVCAPS struct - from Chris Sells book - problem on Windows 2000

Problem using this function to fill LINEDEVCAPS struct - from Chris Sells book - problem on Windows 2000

Post by Angus Combe » Sun, 16 Sep 2001 23:03:25



Hello

I have used the function below in a standard C program and an MFC
application which runs on Microsoft Windows 9x, NT and Windows 2000
platforms without problems.

However, when I use this function in an ATL control it works fine under
Windows 98 and Windows NT v4 but fails on Windows 2000.  As it is straight
from Chris Sells TAPI book I am a bit perplexed.

Has anyone had this experience?   Can anyone see why this might happen.

Under Windows 2000, the second time lineGetDevCaps is called, it fails.

Any feedback would be much appreciated.

If I just do a malloc(<sufficient memory>) it works OK.  But obviously the
dynamic allocation in the code below is much more efficient.

Here is the code:

void CPhone::MyGetLineDevCaps(HLINEAPP hLineApp, DWORD nApiVersion, DWORD
nLineID, LINEDEVCAPS **ppd)
{
    DWORD dwNeededSize = sizeof(LINEDEVCAPS);
    LONG  tr = 0;

    do
    {
        // Get some more memory if we don't have enough
        if( !*ppd || (*ppd)->dwTotalSize < dwNeededSize )
        {
            *ppd = (LPLINEDEVCAPS)::realloc(*ppd,
                                            dwNeededSize);
            if( *ppd )
            {
                (*ppd)->dwTotalSize = dwNeededSize;
            }
            else
            {
//                return LINEERR_NOMEM;
            }
        }

        // Fill in the buffer
        tr = lineGetDevCaps(hLineApp, nLineID, nApiVersion, 0, *ppd);

        // Check how much memory we need
        // (some TSPs succeed even if the
        //  data size is too small)
        if( tr == LINEERR_STRUCTURETOOSMALL ||
            (tr == 0 &&
             (*ppd)->dwTotalSize < (*ppd)->dwNeededSize) )
        {
            dwNeededSize = (*ppd)->dwNeededSize;
            tr = LINEERR_STRUCTURETOOSMALL;
        }
    }
    while( tr == LINEERR_STRUCTURETOOSMALL );

    file://return tr;
// return S_OK;

Quote:}

Angus Comber

 
 
 

Problem using this function to fill LINEDEVCAPS struct - from Chris Sells book - problem on Windows 2000

Post by Michael Dun » Wed, 19 Sep 2001 05:32:12



> Hello

> I have used the function below in a standard C program and an MFC
> application which runs on Microsoft Windows 9x, NT and Windows 2000
> platforms without problems.

> However, when I use this function in an ATL control it works fine under
> Windows 98 and Windows NT v4 but fails on Windows 2000.  As it is straight
> from Chris Sells TAPI book I am a bit perplexed.

> Has anyone had this experience?   Can anyone see why this might happen.

> Under Windows 2000, the second time lineGetDevCaps is called, it fails.

Can you tell us how it fails?  Error codes, etc.  Give an example of how it
normally works and then how it fails.

Quote:> If I just do a malloc(<sufficient memory>) it works OK.  But obviously the
> dynamic allocation in the code below is much more efficient.

It's more memory efficient but takes longer.  All depends on your priorities.

--
Michael Dunn is a TAPI Developer and Tester for Tri-Link Technologies
My TAPI web page:  http://members.home.net/tapifaq/tapi.htm
All opinions are my own, and do not reflect those of my employer.
"When all else fails, read the directions."

 
 
 

1. using window NT server, window 2000 gives problem

I am using Window NT server,but have  some  workstation
window NT , and some have window 2000 workstation. Does
window 2000 store information in the NT server same place
that do the window NT.For example last log on and last log
off,if yes then  window 2000  and window NT store the
information  (log on and log off), where
if No then also both window store the information where.
Thank you for the reply.
fawad

2. EA DATA moved! By itself! I think...

3. PPC2002 - drill down several levels in tree ?

4. using window NT server , window 2000 gives problem

5. Cinemaware returns

6. using window NT server, window 2000 gives problem

7. program association to HTM extension

8. using window NT server , window 2000 give problem

9. Outlook 98, Windows 95 and Chris Sells' sample TSP

10. using window NT server , window 2000 gives problem

11. Have a problem in Workstation window 2000 using window NT server