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

📄 conafilesystem.cs

📁 以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件夹浏览源码,另一个手机SIS安装程序.
💻 CS
📖 第 1 页 / 共 5 页
字号:
        //	ECONA_FILE_TOO_BIG_DEVICE
        //	ECONA_FILE_NAME_INVALID
        //	ECONA_FILE_NAME_TOO_LONG
        //	ECONA_FILE_NOT_FOUND
        //	ECONA_FILE_ALREADY_EXIST
        //	ECONA_FILE_COPYRIGHT_PROTECTED
        //	ECONA_FILE_NO_PERMISSION
        //	ECONA_FILE_NO_PERMISSION_ON_PC
        //	ECONA_FILE_BUSY
        //	ECONA_FILE_TYPE_NOT_SUPPORTED
        //	ECONA_CANCELLED
        //	ECONA_NOTHING_TO_CANCEL
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_NOT_SUPPORTED_DEVICE
        //	ECONA_UNKNOWN_ERROR_DEVICE
        //	ECONA_NOT_INITIALIZED
        //	ECONA_NOT_ENOUGH_MEMORY
        //	ECONA_UNKNOWN_ERROR
        //
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONACopyFile(
            int hFSHandle,
            int iOptions,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrFileName,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrSourcePath,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );

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

        //=========================================================
        // CONARenameFile
        //
        // Description:
        //	CONARenameFile renames the given file.
        //
        // Parameters:
        //	hFSHandle		[in] File System handle.
        //	pstrFileName	[in] Target file name.
        //	pstrNewFileName	[in] New file name.
        //	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_CONNECTION_BUSY
        //	ECONA_CONNECTION_LOST
        //	ECONA_INVALID_DATA_DEVICE
        //	ECONA_MEMORY_FULL
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FILE_NAME_INVALID
        //	ECONA_FILE_NAME_TOO_LONG
        //	ECONA_FILE_NOT_FOUND
        //	ECONA_FILE_ALREADY_EXIST
        //	ECONA_FILE_COPYRIGHT_PROTECTED
        //	ECONA_FILE_NO_PERMISSION
        //	ECONA_FILE_BUSY
        //	ECONA_FILE_TYPE_NOT_SUPPORTED
        //   ECONA_FILE_EXIST
        //	ECONA_NOT_SUPPORTED_DEVICE
        //	ECONA_CANCELLED
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_UNKNOWN_ERROR_DEVICE
        //	ECONA_NOT_INITIALIZED
        //	ECONA_NOT_ENOUGH_MEMORY
        //	ECONA_UNKNOWN_ERROR
        //	
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONARenameFile(
            int hFSHandle,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrFileName,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrNewFileName,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );

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

        //=========================================================
        // CONAReadFile
        //
        // Description:
        //	CONAReadFile reads a file from the device. The Connectivity
        //	API will allocate memory for the file data automatically. 
        //	If the file is empty, pFileData is NULL. The file data 
        //	buffer must be released by using the CONAFreeFileData function.
        //
        // Parameters:
        //	hFSHandle		  [in]  File System handle
        //	pFileInfo		  [in,out]  Target file info and File name 
        //			(or File type) must exist. File size value should be zero.
        //			If it is something else, only that size will be read 
        //          from the beginning of the file.The Connectivity API 
        //			sets the file time (if available) and file size 
        //          (number of bytes in FileData).
        //	ppFileData		  [out] Pointer to the pointer of the file data  
        //	iLimitedReadSize [in]  Reads only the number of bytes from 
        //			the beginning of the file. Value MUST be 0 (zero) when 
        //			the whole file is targeted to be read.
        //	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_CONNECTION_BUSY
        //	ECONA_CONNECTION_LOST
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FILE_NAME_INVALID
        //	ECONA_FILE_NOT_FOUND
        //	ECONA_FILE_COPYRIGHT_PROTECTED
        //	ECONA_FILE_NO_PERMISSION
        //	ECONA_FILE_BUSY
        //	ECONA_CANCELLED
        //	ECONA_NOT_SUPPORTED_DEVICE
        //	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 CONAReadFile(
            int hFSHandle,
            System.IntPtr pFileInfo,
            ref System.IntPtr ppFileData,
            int iLimitedReadSize,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );

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

        //=========================================================
        // CONAWriteFile
        //
        // Description:
        //	CONAWriteFile writes a file onto the device. The file 
        //	data buffer must be allocated by using the CONAAllocFileData 
        //	function, and afterwards the CONAWriteFile buffer must be 
        //	released by using the CONAFreeFileData function. 
        //
        //	If target folder includes same named file, it will be overwrited!
        //
        //	Note: No rollback option! Overwrited data cannot be restored!
        //
        // Parameters:
        //	hFSHandle		[in] File System handle
        //	pFileInfo		[in] Writed file info, File name and 
        //						 file size must be set. 
        //	pFileData		[in] Pointer to file data 
        //	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_CONNECTION_BUSY
        //	ECONA_CONNECTION_LOST
        //	ECONA_FILE_NAME_INVALID
        //	ECONA_INVALID_DATA_DEVICE
        //	ECONA_MEMORY_FULL
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FILE_NAME_INVALID
        //	ECONA_FILE_NAME_TOO_LONG
        //	ECONA_FILE_ALREADY_EXIST
        //	ECONA_FILE_TYPE_NOT_SUPPORTED
        //	ECONA_CANCELLED
        //	ECONA_NOT_SUPPORTED_DEVICE
        //	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 CONAWriteFile(
            int hFSHandle,
            System.IntPtr pFileInfo,
            System.IntPtr pFileData,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );

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

        //=========================================================
        // CONAReadFileInBlocks
        //
        // Description:
        //	CONAReadFileInBlocks function is used to read a file in blocks 
        //	from the device.  
        //	Connectivity API delivers file data blocks via notifications. 
        //	Connectivity API-user must define the maximum file data block 
        //	size used in notifications.
        //	The minimum allowed block size is 64 KBytes (0xFFFF) and maximum 
        //	allowed block size is 32 MBytes (0x1FFFFFF). 
        //
        // Parameters:
        //	hFSHandle			[in] File System handle
        //	pFileInfo			[in,out] Target file info structure pointer
        //		In: File name must be set. 
        //		Out: The Connectivity API sets the file modified time stamp (if available), 
        //		file size, file MIME type (if available) and file attributes. If dwOptions includes  
        //		CONA_NOT_SET_FILE_DETAILS value, Connectivity API is not update file info structure.
        //	dwOptions			[in] Options:
        //		CONA_NOT_SET_FILE_DETAILS: Optional value. Connectivity API is not update file info (pFileInfo) structure.
        //		CONA_USE_IF_NOTICATION:	pFSBlockDataNotify contain pointer to IFSAPIBlockNotify class
        //		CONA_USE_CB_NOTICATION:	pFSBlockDataNotify contain pointer to CONABlockDataCallbackFunction callback function.
        //	pFSBlockDataNotify	[in] Pointer to a notification function.
        //	dwFileDataBlockSize	[in] Used data block size.
        //	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_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FOLDER_NAME_INVALID
        //	ECONA_FILE_NAME_INVALID
        //	ECONA_FILE_NOT_FOUND
        //	ECONA_FILE_COPYRIGHT_PROTECTED
        //	ECONA_FILE_NO_PERMISSION
        //	ECONA_FILE_BUSY
        //	ECONA_CANCELLED
        //	ECONA_NOT_SUPPORTED_DEVICE
        //	ECONA_FAILED_TIMEOUT
        //	ECONA_UNKNOWN_ERROR_DEVICE
        //	ECONA_NOT_INITIALIZED
        //	ECONA_NOT_ENOUGH_MEMORY
        //	ECONA_UNKNOWN_ERROR
        //	
        [DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int CONAReadFileInBlocks(
            int hFSHandle,
            System.IntPtr pFileInfo,
            int iOptions,
            [MarshalAs(UnmanagedType.FunctionPtr)] CONADefinitions.FSBlockDataCallbackDelegate pFSBlockDataNotify,
            int iFileDataBlockSize,
            [MarshalAs(UnmanagedType.LPWStr)] string pstrTargetPath
            );

        //=========================================================
        //
        //=========================================================
        // CONAWriteFileInBlocks
        //
        // Description:
        //	CONAWriteFileInBlocks function is used to write a file in blocks onto the device.
        //	Connectivity API requests file data blocks via notifications. 
        //	Connectivity API-user must define the maximum file data block 
        //	size used in notifications.
        //	The minimum allowed block size is 64 KBytes (0xFFFF) and maximum 
        //	allowed block size is 32 MBytes (0x1FFFFFF). 
        // 	
        //	The tFileTime-struct is used to set modified time stamp to
        //	writed file. If the value is zero or invalid, PC's current time is used. 
        //
        //	If the file size is unknown, dwFileSize parameter must be -1 (0xFFFFFFFF). If
        //	file size is available, value should be set in dwFileSize parameter.
        //	
        //	If target folder includes same named file, it will be overwrited!
        //
        //	Note: No rollback option! Overwrited data cannot be restored!
        //
        // Parameters:
        //	hFSHandle			[in] File System handle
        //	pFileInfo			[in] Writed file info, File name must be set. If file time 
        //		is set and value is valid, that time send to device. Otherwise PC's current time is used.
        //	dwOptions			[in] Options:
        //		CONA_USE_IF_NOTICATION:	pFSBlockDataNotify contain pointer to IFSAPIBlockNotify class
        //		CONA_USE_CB_NOTICATION:	pFSBlockDataNotify contain pointer to CONABlockDataCallbackFunction callback function.
        //	pFSBlockDataNotify	[in] Pointer to a notification function.
        //	dwFileDataBlockSize	[in] Used data block size.
        //	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_MEMORY_FULL
        //	ECONA_CURRENT_FOLDER_NOT_FOUND
        //	ECONA_FOLDER_PATH_TOO_LONG
        //	ECONA_FOLDER_NO_PERMISSION
        //	ECONA_FOLDER_NAME_INVALID
        //	ECONA_FILE_NAME_INVALID
        //	ECONA_FILE_NAME_TOO_LONG
        //	ECONA_FILE_ALREADY_EXIST
        //	ECONA_FILE_TYPE_NOT_SUPPORTED
        //	ECONA_CANCELLED
        //	ECONA_NOTHING_TO_

⌨️ 快捷键说明

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