common.cs

来自「以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件」· CS 代码 · 共 82 行

CS
82
字号
//Filename    : Common.cs
//Part of     : Phone Navigator C# example
//Description : Main module of CSPhoneNavigator.NET example application
//Version     : 3.2
//
//This example is only to be used with PC Connectivity API version 3.2.
//Compability ("as is") with future versions is not quaranteed.
//
//Copyright (c) 2005-2007 Nokia Corporation.
//
//This material, including but not limited to documentation and any related
//computer programs, is protected by intellectual property rights of Nokia
//Corporation and/or its licensors.
//All rights are reserved. Reproducing, modifying, translating, or
//distributing any or all of this material requires the prior written consent
//of Nokia Corporation. Nokia Corporation retains the right to make changes
//to this material at any time without notice. A copyright license is hereby
//granted to download and print a copy of this material for personal use only.
//No other license to any other intellectual property rights is granted. The
//material is provided "as is" without warranty of any kind, either express or
//implied, including without limitation, any warranty of non-infringement,
//merchantability and fitness for a particular purpose. In no event shall
//Nokia Corporation be liable for any direct, indirect, special, incidental,
//or consequential loss or damages, including but not limited to, lost profits
//or revenue,loss of use, cost of substitute program, or loss of data or
//equipment arising out of the use or inability to use the material, even if
//Nokia Corporation has been advised of the likelihood of such damages occurring.

using System.Runtime.InteropServices;
namespace CSPhoneNavigator.NET
{
    using PCCSErrors;
    using CONADefinitions;
    class Common 
    {
        public static PhoneNavigator MainForm;
        public static CONADefinitions.DeviceNotifyCallbackDelegate pDeviceCallBack;

        //===================================================================
        // DeviceNotifyCallback
        //
        // Callback function for device connection notifications
        //
        //===================================================================
        public static int DeviceNotifyCallback( 
            int iStatus, 
            [MarshalAs(UnmanagedType.LPWStr)] string pstrSerialNumber)
        {
            int functionReturnValue = 0;
            try
            {

                functionReturnValue = PCCSErrors.CONA_OK;
                int iCBStatus = CONADefinitions.GET_CONAPI_CB_STATUS(iStatus);
                if (iCBStatus == CONADefinitions.CONAPI_DEVICE_REMOVED)
                {
                    Common.MainForm.bRefreshPhoneListBox = true;
                }
                else if (iCBStatus == CONADefinitions.CONAPI_DEVICE_ADDED)
                {
                    Common.MainForm.bRefreshPhoneListBox = true;
                }
                else if (iCBStatus == CONADefinitions.CONAPI_DEVICE_UPDATED)
                {
                    Common.MainForm.bRefreshPhoneListBox = true;
                }
                else
                {
                    iCBStatus = CONADefinitions.CONAPI_DEVICE_LIST_UPDATED;
                    Common.MainForm.bRefreshPhoneListBox = true;
                }
            }
            catch
            {
                Common.MainForm.bRefreshPhoneListBox = true;
                functionReturnValue = 0;
            }
            return functionReturnValue;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?