⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conaapplicationinstallation.cs

📁 以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件夹浏览源码,另一个手机SIS安装程序.
💻 CS
📖 第 1 页 / 共 2 页
字号:
//Filename    : CONAApplicationInstallation.cs
//Part of     : Connectivity API C# examples
//Description : Connectivity API data definitions, converted from CONADefinitions.h
//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) 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 CONAFileSystem
{
    class CONAApplicationInstallation
    {
        ///////////////////////////////////////////////////////////////////////
        //// Connectivity API Application Installation definitions and function
        ///////////////////////////////////////////////////////////////////////

        // The next define values used to define which type of struct is used:
        // Use when struct type is CONAPI_APPLICATION_SIS
        public const int CONA_APPLICATION_TYPE_SIS = 1;
        // Use when struct type is CONA_APPLICATION_TYPE_JAVA
        public const int CONA_APPLICATION_TYPE_JAVA = 2;
        // Use when struct type is CONAPI_APPLICATION_THEMES
        public const int CONA_APPLICATION_TYPE_THEMES = 4;
        // Use only in CONAPI_APPLICATION_INFO struct, unknown application type.
        public const int CONA_APPLICATION_TYPE_UNKNOWN = 8;
        // Default uninstallation, used with CONAUninstallApplication function.
        public const int CONA_DEFAULT_UNINSTALLATION = 256;
        // Silent uninstallation, used with CONAUninstallApplication function.
        public const int CONA_SILENT_UNINSTALLATION = 512;
        //
        public const int CONA_LIST_ALL_APPICATIONS = 4096;
        // List all installed java applications, used with CONAListApplications function
        public const int CONA_LIST_JAVA_APPICATIONS = 8192;
        // List all installed themes, used with CONAListApplications function
        public const int CONA_LIST_THEMES_APPICATIONS = 16384;


        // The struct for sis applications
        public struct CONAPI_APPLICATION_SIS
        {
            [MarshalAs(UnmanagedType.LPWStr)]   // sis application File name, must be set 
            public string pstrFileNameSis;      // The value can also include the file path in PC.                                
        }

        // The struct for java applications
        [StructLayout(LayoutKind.Sequential)]
        public struct CONAPI_APPLICATION_JAVA
        {
            [MarshalAs(UnmanagedType.LPWStr)]   // File name of the jad file. The value can also include the file path in PC.
            public string pstrFileNameJad;      //If jad file is not available, the value must be NULL.  
            [MarshalAs(UnmanagedType.LPWStr)]   // File name of the jar file, must be set. 
            public string pstrFileNameJar;      // The value can also include the file path in PC.

        }

        // The struct for themes file
        [StructLayout(LayoutKind.Sequential)]
        public struct CONAPI_APPLICATION_FILE
        {
            [MarshalAs(UnmanagedType.LPWStr)]   // File name of the nth file, must be set
            public string pstrFileName;         // The value can also include the file path in PC.		
            public int iOptions;                // Reserved for future use, the value must be 0.
        }

        //The struct for application info, used with CONAListApplications function
        public struct CONAPI_APPLICATION_INFO
        {
            public int dwSize;                  // Size of struct in bytes.
            [MarshalAs(UnmanagedType.LPWStr)]   // Application name. Always exist.
            public string pstrName;
            [MarshalAs(UnmanagedType.LPWStr)]   // Application description. If not available, pointer is NULL.
            public string pstrDescription;
            [MarshalAs(UnmanagedType.LPWStr)]   // Application vendor. If not available, pointer is NULL.
            public string pstrVendor;
            [MarshalAs(UnmanagedType.LPWStr)]   // Application version. If not available, pointer is NULL.
            public string pstrVersion;
            [MarshalAs(UnmanagedType.LPWStr)]   // Parent application name. This is available if application is augmentation 
            public string pstrParentAppNam;
            // Application size in bytes. If not available, value is -1 (0xFFFFFFFF).
            //                                            for some other application. 
            public int dwApplicationSize;
            // Application type possible values:
            //	                                CONA_APPLICATION_TYPE_SIS		:	Sis application
            //								    CONA_APPLICATION_TYPE_JAVA		:	Java application
            //								    CONA_APPLICATION_TYPE_THEMES    :	Themes application	
            //								    CONA_APPLICATION_TYPE_UNKNOWN	:	Application type is not available
            public int dwApplicationType;
            [MarshalAs(UnmanagedType.LPWStr)]   // Application UID string, used with CONAUninstallApplication function.
            public string pstrUID;              // Reserved for future use. Value is zero.
            public int dwOptions;
            [MarshalAs(UnmanagedType.LPWStr)]   // Reserved for future use. Pointer is NULL.
            public string pstrValue;
        }

        [DllImport("ConnAPI", EntryPoint = "CONAInstallApplication", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]

        //=========================================================
        // CONAInstallXXXApplication 
        //
        // Description:
        //	CONAInstallApplication installs the given application on 
        //	the device. FS's CONACancel function can be used to cancel 
        //	this function. The application file name(s) must be given 
        //	in the CONAPI_APPLICATION_SIS or CONAPI_APPLICATION_JAVA 
        //	structure. 
        //	
        //	The function also checks the amount of free memory from 
        //	the phone before the installation. If there is not enough 
        //	memory left in the target memory drive, the function fails 
        //	with the error code ECONA_MEMORY_FULL.
        //	
        //	If the Application file type is sis, the CONAPI_APPLICATION_SIS 
        //	structure must be used. The iAppicationType parameter's 
        //	value must be CONA_APPLICATION_TYPE_SIS.
        //	
        //	If the Application file type is jar, the CONAPI_APPLICATION_JAVA 
        //	structure must be used. The iAppicationType parameter's 
        //	value must be CONA_APPLICATION_TYPE_JAVA.
        //
        // Parameters:
        //	hFSHandle			[in] File System handle
        //	iApplicationType	[in] Used struct type: CONA_APPLICATION_TYPE_SIS or 
        //											   CONA_APPLICATION_TYPE_JAVA
        //	pApplicationStruct	[in] Pointer to CONAPI_APPLICATION_SIS or 
        //							 CONAPI_APPLICATION_JAVA struct.
        //	iOptions			[in] Options: 
        //		CONA_DEFAULT_FOLDER: Copies the application to the device's default 
        //		application folder automatically and starts the device's installer 
        //		(if required to do so).Target path or current folder is not used.  
        //		CONA_OVERWRITE:	Overwrites the application file if it already 
        //		exists in the target folder.
        //
        //	pstrSourcePath		[in] Source folder path on the PC. The value must be NULL, 
        //							 if path is given with file name(s) in Application structure.
        //	pstrTargetPath   	[in] Target folder.If NULL, current folder is used.
        //							 If CONA_DEFAULT_FOLDER is used,Application will 
        //							 be installed to device's default application folder. 
        //
        // Return values:
        // CONA_OK
        // ECONA_INVALID_HANDLE
        // ECONA_INVALID_PARAMETER
        // ECONA_CONNECTION_BUSY
        // ECONA_CONNECTION_LOST
        // ECONA_INVALID_DATA_DEVICE
        // ECONA_MEMORY_FULL
        // ECONA_CURRENT_FOLDER_NOT_FOUND
        // ECONA_FOLDER_PATH_TOO_LONG
        // ECONA_FOLDER_NOT_FOUND
        // ECONA_FOLDER_NO_PERMISSION_ON_PC
        // ECONA_FILE_TOO_BIG_DEVICE
        // ECONA_FILE_NAME_INVALID

⌨️ 快捷键说明

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