开发者

lineTranslateAddress c++ to managed c#

开发者 https://www.devze.com 2023-03-05 02:57 出处:网络
I have an application that programatically makes calls to different numbers. The application is writ开发者_如何学Goten in c# (managed) and I use pInvoke for the c++ TAPI functions. Everything works fi

I have an application that programatically makes calls to different numbers. The application is writ开发者_如何学Goten in c# (managed) and I use pInvoke for the c++ TAPI functions. Everything works fine except the fact that I need to convert the phone number to a the dialable format.

To do this conversion, I have to use the C++ function lineTranslateAddress, but from C#. Has anyone used this function from managed code and can provide me some samples or at least explanations.

Maybe some indications how to marshall / nmarshall the last field

LPLINETRANSLATEOUTPUT lpTranslateOutput

I should also mention that the application is for a smart device.

Thanks,


I used this code example, and it works

[DllImport("coredll", SetLastError = true)]
extern public static int lineTranslateAddress(
    IntPtr hLineApp,
    int dwDeviceID,
    int dwAPIVersion,
    string lpszAddressIn,
    int dwCard,
    int dwTranslateOptions,
    byte[] lpTranslateOutput
    );


I've worked with TAPI in C# on several occasions, and I would strongly suggest using a Runtime Callable Wrapper (RCW) instead of using Platform Invoke. C:\windows\system32\tapi3.dll can be added as a project reference and VS will automatically generated an interop assembly that you can use to work with the classes and functions.

This way, you will be able to call the lineTranslateAddress function with great ease; via the ITAddressTranslation interface.

Note: Even if your TSP only complies with TAPI 2.x, you can still use the functionality in tapi3.dll (providing you only call the subset of features supported by TAPI 2)

0

精彩评论

暂无评论...
验证码 换一张
取 消