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

📄 conafilesystem.cs

📁 以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件夹浏览源码,另一个手机SIS安装程序.
💻 CS
📖 第 1 页 / 共 5 页
字号:
        //
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONAGetMemoryValues(
            int hFSHandle,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrMemoryType,
            ref System.Int64 pdlFree,
            ref System.Int64 pdlTotal,
            ref System.Int64 pdlUsed
            );

        //=========================================================

        //=========================================================
        // CONASetCurrentFolder
        //
        // Description:
        // CONASetCurrentFolder sets the device's current folder. All 
        // file and folder operations with a relative path reference 
        // will use this value. After the connection is established, 
        // the default value is the device's root-folder. Only backslashes 
        // ("\") are permissible folder separators.
        // 
        // Any other FS operation does not change the current folder. 
        // If CONASetCurrentFolder fails, the currect folder is not changed. 
        //
        // Parameters:
        //	hFSHandle	[in] File System handle
        //	pstrPath	[in] Name of the new current folder. Its value may 
        //					 be a relative or absolute reference. If the 
        //					 absolute path is used, the first two characters 
        //					 must be backslashes "\\". If you set the current 
        //					 folder to the root-folder, the path must include 
        //					 only two backslash characters "\\".
        //					 If the current folder is required to move sub folder, 
        //					 the path must not include any backslashes.
        //					 If the current folder is required to change the 
        //					 parent folder, the first two characters must be dots
        //					 and the third character must be a backslash "..\". 
        //
        // Return values:
        //	CONA_OK
        //	ECONA_INVALID_HANDLE
        //	ECONA_INVALID_PARAMETER
        //	ECONA_CONNECTION_BUSY
        //	ECONA_CONNECTION_LOST
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FOLDER_NAME_INVALID_DEVICE
        //	ECONA_FOLDER_NO_PERMISSION
        //	ECONA_CANCELLED
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_UNKNOWN_ERROR_DEVICE
        //	ECONA_NOT_INITIALIZED
        //	ECONA_UNKNOWN_ERROR
        //
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONASetCurrentFolder(
            int hFSHandle,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrPath
            );

        //=========================================================

        //=========================================================
        // CONAGetCurrentFolder
        //
        // Description:
        // CONAGetCurrentFolder returns the current folder, which is 
        // set by using the CONASetCurrentFolder function.
        //
        // Parameters:
        //	hFSHandle		[in]  File System handle
        //	ppstrPath		[out] Pointer to the WCHAR receiving 
        //						  the current folder.
        //	
        //
        // Return values:
        //	CONA_OK
        //	ECONA_INVALID_HANDLE
        //	ECONA_INVALID_POINTER
        //	ECONA_CONNECTION_LOST
        //	ECONA_CANCELLED
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_NOT_INITIALIZED
        //	ECONA_UNKNOWN_ERROR	
        //
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONAGetCurrentFolder(
            int hFSHandle,
            [MarshalAs(UnmanagedType.LPWStr)] ref string ppstrPath
            );

        //=========================================================

        //=========================================================
        // CONAFindBegin
        //
        // Description:
        // CONAFindBegin starts find files and subfolders from currect 
        // folder or target path. If target path is used, path must be 
        // absolute path.Find option:
        // CONA_FIND_USE_CACHE	  Use cache if it is available.
        //
        // Parameters:
        //	hFSHandle		[in]  File System handle
        //	iFindOptions	[in]  Find options:If CONA_FIND_USE_CACHE option
        //						  is not used, value must be 0.
        //	pFileHandle		[out] Pointer to find handle
        //	pstrTargetPath	[in]  Target path. If the path is NULL, 
        //						  the current folder is used 
        //
        // Return values:
        //	CONA_OK
        //	ECONA_INVALID_HANDLE
        //	ECONA_INVALID_PARAMETER
        //	ECONA_INVALID_POINTER
        //	ECONA_CONNECTION_BUSY
        //	ECONA_CONNECTION_LOST
        //	ECONA_INVALID_DATA_DEVICE
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_CANCELLED
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_UNKNOWN_ERROR_DEVICE
        //	ECONA_NOT_INITIALIZED
        //  ECONA_NOT_ENOUGH_MEMORY
        //	ECONA_UNKNOWN_ERROR
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FOLDER_NAME_INVALID_DEVICE
        //	ECONA_FOLDER_NO_PERMISSION
        //
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONAFindBegin(
            int hFSHandle,
            int iFindOptions,
            ref int phFindHandle,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );
        //=========================================================

        //=========================================================
        // CONAFindNextFolder
        //
        // Description:
        // CONAFindNextFolder returns the folder information for one 
        // folder and continues the search to the next folder. The 
        // folder information is returned with the CONAPI_FOLDER_INFO 
        // structure. The allocated memory MUST be freed by calling 
        // the CONAFreeFolderInfoStructure function.
        //
        // Parameters:
        //	hFindHandle		[in]  Find handle
        //	pFolderInfo		[out] Pointer to the folder's info struct.
        //
        // Return values:
        //	CONA_OK
        //	ECONA_ALL_LISTED
        //	ECONA_INVALID_HANDLE
        //	ECONA_INVALID_POINTER
        //	ECONA_NOT_INITIALIZED
        //	ECONA_UNKNOWN_ERROR
        //
        //=========================================================
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONAFindNextFolder(
            int hFindHandle,
            System.IntPtr pFolderInfo
            );

        //=========================================================
        // CONAFindNextFile
        //
        // Description:
        // CONAFindNextFile returns file information for one file, 
        // and continues the search to the next file. File information 
        // is returned with the CONAPI_FILE_INFO structure. Allocated 
        // memory MUST be freed by calling CONAFreeFileInfoStructure function.
        //
        // Parameters:
        //	hFindHandle		[in]  Find handle
        //	pFileInfo		[out] Pointer to the file's info struct.
        //
        // Return values:
        //	CONA_OK
        //	ECONA_ALL_LISTED
        //	ECONA_INVALID_HANDLE
        //	ECONA_INVALID_POINTER
        //	ECONA_NOT_INITIALIZED
        //	ECONA_UNKNOWN_ERROR
        //
        //=========================================================
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONAFindNextFile(
            int hFindHandle,
            System.IntPtr pFileInfo
            );

        //=========================================================
        // CONAFindEnd
        //
        // Description:
        // CONAFindEnd closes find handle.
        //
        //
        // Parameters:
        //	hFindHandle		[in]  Find handle
        //
        // Return values:
        //	CONA_OK
        //	ECONA_INVALID_HANDLE
        //
        //=========================================================
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONAFindEnd(int hFindHandle);

        //=========================================================
        // CONACreateFolder
        //
        // Description:
        // CONACreateFolder creates a new folder onto the device. 
        // The function fails if the folder already exists on the device.
        //
        // Parameters:
        //	hFSHandle		[in] File System handle
        //	pstrFolderName	[in] New folder name string
        //	pstrTargetPath	[in] Target path. If path is NULL, current 
        //						 folder is used. 
        //
        // Return values:
        //	CONA_OK
        //	ECONA_INVALID_HANDLE
        //	ECONA_INVALID_PARAMETER
        //	ECONA_CONNECTION_BUSY
        //	ECONA_CONNECTION_LOST
        //	ECONA_INVALID_DATA_DEVICE
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FOLDER_NAME_INVALID_DEVICE
        //	ECONA_FOLDER_ALREADY_EXIST
        //	ECONA_FOLDER_NO_PERMISSION
        //	ECONA_CANCELLED
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_UNKNOWN_ERROR_DEVICE
        //	ECONA_NOT_INITIALIZED
        //	ECONA_UNKNOWN_ERROR
        //
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONACreateFolder(
            int hFSHandle,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrFolderName,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );

        //=========================================================

        //=========================================================
        // CONADeleteFolder
        //
        // Description:
        // CONADeleteFolder deletes a folder from the device. This 
        // function does not delete the folder if the folder includes 
        // any subfolder(s)! Only an empty folder and a folder that 
        // contains files can be deleted. If the folder does not include 
        // a DELETE-permission, the function fails.
        //
        // Note: No rollback option! Deleted data cannot be restored!
        //
        // Parameters:
        //	hFSHandle		[in] File System handle
        //	pstrFolderName	[in] Folder name string
        //	iDeleteOptions	[in] Delete options. Possible values: 
        //			CONA_DELETE_FOLDER_EMPTY:		Only an empty folder can be deleted.
        //			CONA_DELETE_FOLDER_WITH_FILES:  Only a folder that contains file(s) can be deleted.
        //	pstrTargetPath	[in] Target path. If path is NULL, current
        //						 folder is used.  
        //
        // Return values:
        //	CONA_OK
        //	ECONA_INVALID_HANDLE
        //	ECONA_INVALID_PARAMETER
        //	ECONA_CONNECTION_BUSY
        //	ECONA_CONNECTION_LOST
        //	ECONA_INVALID_DATA_DEVICE
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_NOT_EMPTY
        //	ECONA_FOLDER_NO_PERMISSION
        //	ECONA_CANCELLED
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_UNKNOWN_ERROR_DEVICE
        //	ECONA_NOT_INITIALIZED
        //	ECONA_UNKNOWN_ERROR
        //
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONADeleteFolder(
            int hFSHandle,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrFolderName,
            int iDeleteOptions,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );

⌨️ 快捷键说明

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