📄 conafilesystem.cs
字号:
//Filename : CONAFileSystem.cs
//Part of : Connectivity API C# examples
//Description : Connectivity API data definitions, converted from CONAFileSystem.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
{
using CONADefinitions;
class CONAFileSystem
{
//=========================================================
// File System API versions
//
public const short FSAPI_VERSION_30 = 30;
public const short FSAPI_VERSION_31 = 31;
public const short FSAPI_VERSION_32 = 32;
//=========================================================
//
//=========================================================
// FSAPI_Initialize
//
// Description:
// FSAPI_Initialize initializes the API. This must be called once and before any other FSAPI call!
// It's not allowed to call this function like this
// FSAPI_Initialize(FSAPI_GetAPIVersion(), NULL);
// You must call it like this
// FSAPI_Initialize(FSAPI_VERSION_32, NULL);
//
// Parameters:
// dwAPIVersion [in] FSAPI version requested.
// pdwParam [in] Reserved for future use. Must be NULL.
//
// Return values:
//
[DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int FSAPI_Initialize(
int iAPIVersion,
System.IntPtr pdwParam
);
//=========================================================
//
//=========================================================
// FSAPI_Terminate
//
// Description:
// FSAPI_Terminate terminates the API. This must be called once and as the last FSAPI call!
//
// Parameters:
// pdwParam [in] Reserved for future use. Must be NULL.
//
// Return values:
//
[DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int FSAPI_Terminate(System.IntPtr pdwParam);
//=========================================================
//
//=========================================================
// FSAPI_GetAPIVersion
//
// Description:
// Returns currently installed version of this FSAPI.
//
// Parameters:
//
// Return values:
// API version number.
//
[DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int FSAPI_GetAPIVersion();
/////////////////////////////////////////////////////////////
// ConnectivityAPI File System functions
/////////////////////////////////////////////////////////////
//=========================================================
// CONAOpenFS
//
// Description:
// CONAOpenFS opens a file system (FS) connection to the target
// device. The function sets the FS Connection handle, which
// identifies different client connections. It will be placed
// into the given pointer.
//
// If the media type is API_MEDIA_ALL, the ServiceLayer selects
// the used media type automatically by applying the following rule:
// If there is an open FS connection to the device, it will be used.
// Otherwise the ServiceLayer tries to open the FS connection in the
// following order: USB, Seria, Irda and BT (if the device is
// connected via medias). The function also sets the DeviceID,
// which can be used to identify the used media type.
//
// If the Serial Number is an empty string, the function tries to
// open the FS connection by using the piDeviceID parameter. The
// piMedia parameter is not used in the exemplary case.
//
// Parameters:
// pstrSerialNumber [in] The device's serial number, which must be set.
// piMedia [in,out] In: Media type, which defines the target
// media for the Device's FS connection.
// Out:If the value is API_MEDIA_ALL, the
// target media is selected automatically
// and the used media type is returned.
// phFSHandle [out] Handle to the opened FS connection
// piDeviceID [in,out] In: Device ID. Used only when the Serial
// number is empty string.
// Out: Returned Device ID value of the connected device.
//
// Return values:
// CONA_OK
// ECONA_DEVICE_NOT_FOUND
// ECONA_NO_CONNECTION_VIA_MEDIA
// ECONA_NOT_SUPPORTED_DEVICE
// ECONA_CONNECTION_FAILED
// ECONA_CONNECTION_BUSY
// ECONA_CONNECTION_LOST
// ECONA_FAILED_TIMEOUT
// ECONA_INVALID_POINTER
// ECONA_NOT_INITIALIZED
// ECONA_NOT_SUPPORTED_MANUFACTURER
// ECONA_NOT_ENOUGH_MEMORY
// ECONA_UNKNOWN_ERROR
//
[DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int CONAOpenFS(
[MarshalAs(UnmanagedType.LPWStr)] string pstrSerialNumber,
ref int piMedia,
ref int phFSHandle,
ref int piDeviceID
);
//=========================================================
//=========================================================
// CONACloseFS
//
// Description:
// CONACloseFS closes the given file system connection.
//
// Parameters:
// hFSHandle [in] Existing file system handle
//
// Return values:
// CONA_OK
// ECONA_INVALID_HANDLE
// ECONA_NOT_INITIALIZED
// ECONA_UNKNOWN_ERROR
//
//=========================================================
[DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int CONACloseFS(int hFSHandle);
//=========================================================
// CONARegisterFSNotifyCallback
//
// Description:
// CONARegisterFSNotifyCallback registers or unregisters the
// callback function for the file functions' status notifications.
//
// During file operations, the connectionAPI calls this function
// with the parameter's state (0-100%), connection handle, and
// operation code.
//
// Parameters:
// hFSHandle [in] File System handle
// iState [in] Register flag:
// API_REGISTER: Registers a callback function
// API_UNREGISTER: Unregisters a callback function
// pFSNotify [in] Pointer to a function.
//
// Return values:
// CONA_OK
// ECONA_INVALID_HANDLE
// ECONA_INVALID_POINTER
// ECONA_INVALID_PARAMETER
// ECONA_NOT_INITIALIZED
// ECONA_UNKNOWN_ERROR
//
//=========================================================
[DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int CONARegisterFSNotifyCallback(
int hFSHandle,
int iState,
CONADefinitions.FSNotifyCallbackDelegate pFSNotify
);
//=========================================================
// CONARefreshDeviceMemoryValues
//
// Description:
// CONARefreshDeviceMemoryValues refreshes the memory values
// from the device. The function caches the memory values, so
// it must be called if it is required to get the latest information.
//
// Parameters:
// hFSHandle [in] File system handle
//
// Return values:
// CONA_OK
// ECONA_INVALID_HANDLE
// ECONA_CONNECTION_BUSY
// ECONA_CONNECTION_LOST
// ECONA_INVALID_DATA_DEVICE
// 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 CONARefreshDeviceMemoryValues(int hFSHandle);
//=========================================================
// CONAGetMemoryTypes
//
// Description:
// CONAGetMemoryTypes receives all memory types that currently
// exist in the device. The format of its string is
// "Memory type string" comma "next Memory type string". An
// example of a string is "DEV,MMC,APPL".
//
// The device can include different memory types. For example,
// the memory types can be "DEV" (device memory), "MMC"
// (memory card), or "APPL" (device special memory).
//
// Parameters:
// hFSHandle [in] File system handle.
// ppstrMemoryTypes [out] Memory types.
//
// Return values:
// CONA_OK
// ECONA_INVALID_HANDLE
// ECONA_INVALID_POINTER
// ECONA_NOT_SUPPORTED_DEVICE
// ECONA_NOT_INITIALIZED
// ECONA_UNKNOWN_ERROR
//
[DllImport("ConnAPI", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int CONAGetMemoryTypes(
int hFSHandle,
[MarshalAs(UnmanagedType.LPWStr)] ref string ppstrMemoryTypes
);
//=========================================================
//=========================================================
// CONAGetMemoryValues
//
// Description:
// CONAGetDeviceMemory returns info about the given device memory type.
//
// Parameters:
// hFSHandle [in] File System handle.
// pstrMemoryType [in] Inquired device memory.E.g. "DEV", "MMC",
// or "APPL".If the value is NULL, the used value is "DEV".
// pdlFree [out] Pointer to the variable receiving the
// information on the amount of free memory.
// If not available, the value is -1.
// pdlTotal [out] Pointer to the variable receiving
// the information on the total memory.
// If not available, the value is -1.
// pdlUsed [out] Pointer to the variable receiving
// the information on the used memory.
// If not available, the value is -1.
//
// Return values:
// CONA_OK
// ECONA_INVALID_HANDLE
// ECONA_INVALID_POINTER
// ECONA_INVALID_PARAMETER
// ECONA_NOT_SUPPORTED_DEVICE
// ECONA_NOT_INITIALIZED
// ECONA_UNKNOWN_ERROR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -