TAPI lineIntializeEx() Compact Framework V1

I have an application that successfully uses the TAPI functions with a .Net Compact Framework Version 2. I am trying to port that to Compact Framework Version 1 and am having issues.

Here are my structure and method definitions:

public delegate void LineCallBack(System.UInt32 dwDevice, System.UInt32 dwMessage, System.UInt32 dwInstance,

System.UInt32 dwParam1, System.UInt32 dwParam2, System.UInt32 dwParam3);

public struct lineinitializeexparams

{

public uint dwTotalSize;

public uint dwNeededSize;

public uint dwUsedSize;

public uint dwOptions;

public System.IntPtr hEvent;

public uint dwCompletionKey;

}

[DllImport("coredll.dll", SetLastError = true)]

internal static extern LineErrReturn lineInitializeEx(

out IntPtr hLineApp,

IntPtr hAppHandle,

LineCallBack lCalllBack,

string FriendlyAppName,

out System.UInt32 NumDevices,

ref System.UInt32 APIVersion,

ref lineinitializeexparams lineExInitParams);

// prepare the lineinitializeexparams

lineinitializeexparams initparams = new lineinitializeexparams();

initparams.dwTotalSize = (uint) Marshal.SizeOf(initparams);

initparams.dwNeededSize = initparams.dwTotalSize;

initparams.dwUsedSize = initparams.dwTotalSize;

initparams.hEvent = System.IntPtr.Zero;

initparams.dwOptions = (uint)opts;

LineErrReturn ret = lineInitializeEx(out m_hTapi, System.IntPtr.Zero,

m_CallBack, "Test", out m_numberDevices,

ref m_TapiVersion, ref initparams);

This throws a NotSupportedException. If I replace the m_CallBack parameter and function definition with System.IntPtr.Zero and System.IntPtr, respectively, then an exception is not thrown, but I get an INVALID POINTER error returned.

Any ideas

Thanks

Harry



Answer this question

TAPI lineIntializeEx() Compact Framework V1

  • Divya Bhasin

    Ok. So, can I modify the function definition to be:

    [DllImport("coredll.dll", SetLastError = true)]

    internal static extern LineErrReturn lineInitializeEx(

    out IntPtr hLineApp,

    IntPtr hAppHandle,

    IntPtr lCallBack,

    string FriendlyAppName,

    out System.UInt32 NumDevices,

    ref System.UInt32 APIVersion,

    ref lineinitializeexparams lineExInitParams);

    I did the above and called the method as:

    LineErrReturn ret = lineInitializeEx(out m_hTapi, m_AppHandle, System.IntPtr.Zero, "Test", out m_numberDevices, ref m_TapiVersion, ref initparams)

    At that point, the exception was not thrown, but an INVALID POINTER error was returned. Do you know if that would refer to the initparams structure Or is there still something wrong with the lineInitializeEx() declaration

    Thanks

    Harry


  • Rob Wheeler

    you should check out OpenNETCF Telephony Library 1.0. I have been using it since beta for an internal application with Mobile 5 and it is pretty good.

    http://www.opennetcf.com/CompactFramework/Products/TelephonyLibrary/tabid/134/Default.aspx



    It is GA now.

  • JPATEL

    Ilya -

    The problem was that I was using the hiddenwindow option. Since call backs are not supported, this was the problem. I changed it to the useevent option and it works now.

    Thank you for your help


  • Ken32767

    It looks good to me. The only question I have - what is hAppHandle is set to



  • MagicM

    Not sure how exactly it's used by TAPI, but NULL you’re passing is the valid value, so you should be OK here.

    Just a hunch - try declaring lineinitializeexparams as a class instead of structure, remove "ref" from P/Invoke declaration.



  • Steve Hempen

    NETCF V1 does not support call backs from native to managed so that is not possible.



  • Fran431916

    I have hAppHandle set to System.InitPtr.Zero, just as I did when working with Compact Framework V2. Do you know what the AppHandle is used for internally

    Thanks

    Harry


  • TAPI lineIntializeEx() Compact Framework V1