Click here to Skip to main content
15,893,161 members
Articles / Programming Languages / C#

Windows Mobile Programming Tricks on the .NET Compact Framework: Part 1

Rate me:
Please Sign up or sign in to vote.
4.64/5 (8 votes)
23 Feb 2011CPOL4 min read 41.1K   668   24  
The article provides and describes some useful code snippets for Windows Mobile/CE developers.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BeeMobile
{
    internal class LINEGENERALINFO
    {
        public int dwManufacturerOffset;
        public int dwManufacturerSize;
        public int dwModelOffset;
        public int dwModelSize;
        public int dwNeededSize;
        public int dwRevisionOffset;
        public int dwRevisionSize;
        public int dwSerialNumberOffset;
        public int dwSerialNumberSize;
        public int dwSubscriberNumberOffset;
        public int dwSubscriberNumberSize;
        public int dwTotalSize;
        public int dwUsedSize;
    }

    [StructLayout(LayoutKind.Sequential)]
    internal struct LINEEXTENSIONID
    {
        public IntPtr dwExtensionID0;
        public IntPtr dwExtensionID1;
        public IntPtr dwExtensionID2;
        public IntPtr dwExtensionID3;
    }

    [StructLayout(LayoutKind.Sequential)]
    internal struct LINEINITIALIZEEXPARAMS
    {
        public uint dwTotalSize;
        public uint dwNeededSize;
        public uint dwUsedSize;
        public uint dwOptions;
        public System.IntPtr hEvent;
        public System.IntPtr hCompletionPort;
        public uint dwCompletionKey;
    }

    /// <summary>
    /// simple managed wrapper for the Telephony API
    /// </summary>
    internal class Tapi
    {
        [DllImport("coredll")]
        public static extern int lineInitializeEx(out IntPtr lpm_hLineApp, IntPtr hInstance, IntPtr lpfnCallback, string lpszFriendlyAppName, out int lpdwNumDevs, ref int lpdwAPIVersion, ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams);

        [DllImport("coredll")]
        public static extern int lineOpen(IntPtr m_hLineApp, int dwDeviceID, out IntPtr lphLine, int dwAPIVersion, int dwExtVersion, IntPtr dwCallbackInstance, int dwPrivileges, int dwMediaModes, IntPtr lpCallParams);

        [DllImport("coredll")]
        public static extern int lineNegotiateAPIVersion(IntPtr m_hLineApp, int dwDeviceID, int dwAPILowVersion, int dwAPIHighVersion, out int lpdwAPIVersion, out LINEEXTENSIONID lpExtensionId);

        [DllImport("cellcore")]
        public static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bytes);

        [DllImport("cellcore")]
        public static extern int lineGetGeneralInfo(IntPtr hLine, ref LINEGENERALINFO lineGenerlInfo);

        [DllImport("coredll")]
        public static extern int lineClose(IntPtr hLine);

        [DllImport("coredll")]
        public static extern int lineShutdown(IntPtr m_hLineApp);
        
    }


}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
G&M Dynamics, s.r.o.
Slovakia Slovakia
I work for Bee Mobile.

Web site: http://beemobile4.net
Facebook site: http://facebook.com/BeeMobile
YouTube Channel: http://youtube.com/beemobile4dotnet

Comments and Discussions