📄 conadevicemanagement.vb
字号:
'Filename : CONADeviceManagement.vb
'Part of : PCSAPI VB.NET examples
'Description : Device management API, converted from CONADeviceManagement.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.
Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices
Module CONADeviceManagement
'///////////////////////////////////////////////////////////
'// Device management API
'///////////////////////////////////////////////////////////
' //=========================================================
' // Device Management API versions
' //
Public Const DMAPI_VERSION_30 As Short = 30
Public Const DMAPI_VERSION_31 As Short = 31
Public Const DMAPI_VERSION_32 As Short = 32
' //=========================================================
' //=========================================================
' // DMAPI_Initialize
' //
' // Description:
' // DMAPI_Initialize initializes the API. This must be called once and before any other DMAPI call!
' // It's not allowed to call this function like this
' // DMAPI_Initialize(DMAPI_GetAPIVersion(), NULL);
' // You must call it like this
' // DMAPI_Initialize(DMAPI_VERSION_30, NULL);
' //
' // Parameters:
' // dwAPIVersion [in] DMAPI version requested.
' // pdwParam [in] Reserved for future use. Must be NULL.
' //
' // Return values:
' //
Public Declare Unicode Function DMAPI_Initialize Lib "ConnAPI" (ByVal dwAPIVersion As Integer, ByVal pdwParam As Integer) As Integer
' //=========================================================
' //=========================================================
' // DMAPI_Terminate
' //
' // Description:
' // DMAPI_Terminate terminates the API. This must be called once and as the last DMAPI call!
' //
' // Parameters:
' // pdwParam [in] Reserved for future use. Must be NULL.
' //
' // Return values:
' //
Public Declare Function DMAPI_Terminate Lib "ConnAPI" (ByVal iValue As Integer) As Integer
' //=========================================================
' //=========================================================
' // DMAPI_GetAPIVersion
' //
' // Description:
' // Returns currently installed version of this DMAPI.
' //
' // Parameters:
' //
' // Return values:
' // API version number.
' //
Public Declare Function DMAPI_GetAPIVersion Lib "ConnAPI" () As Integer
' //=========================================================
'///////////////////////////////////////////////////////////
'// Device management API
'///////////////////////////////////////////////////////////
' //=========================================================
' // CONAOpenDM
' //
' // Description:
' // Returns the handle to the device manager
' //
' // Parameters:
' // phDMHandle [out] Device manager handle
' //
' // Return values:
' // CONA_OK
' // ECONA_INVALID_POINTER
' // ECONA_NOT_INITIALIZED
' // ECONA_INIT_FAILED_COM_INTERFACE
' // ECONA_UNKNOWN_ERROR
' //
Public Declare Function CONAOpenDM Lib "ConnAPI" (ByRef hDMHandle As Integer) As Integer
' //=========================================================
' //=========================================================
' // CONACloseDM
' //
' // Description:
' // Closes the handle to the device manager
' //
' // Parameters:
' // hDMHandle [in] Device manager handle
' //
' // Return values:
' // CONA_OK
' // ECONA_INVALID_POINTER
' // ECONA_NOT_INITIALIZED
' // ECONA_UNKNOWN_ERROR
' //
Public Declare Function CONACloseDM Lib "ConnAPI" (ByVal hDMHandle As Integer) As Integer
' //=========================================================
' //=========================================================
' // CONAGetDeviceCount
' //
' // Description:
' // Returns number of available devices
' //
' // Parameters:
' // hDMHandle [in] Device manager handle
' // iCount [out] Number of devices
' //
' // Return values:
' // CONA_OK
' // ECONA_INVALID_POINTER
' // ECONA_NOT_INITIALIZED
' // ECONA_UNKNOWN_ERROR
' //
Public Declare Function CONAGetDeviceCount Lib "ConnAPI" (ByVal hDMHandle As Integer, ByRef iCount As Integer) As Integer
' //=========================================================
' //=========================================================
' // CONAGetDevices
' //
' // Description:
' // Returns needed number of devices
' //
' // Parameters:
' // hDMHandle [in] Device manager handle
' // iCount [in,out] In: Number of allocated CONAPI_DEVICE structs.
' // Out: Number of used CONAPI_DEVICE structs.
' // pDevices [out] Pointer to receiving CONAPI_DEVICE structures.
' //
' // Return values:
' // CONA_OK
' // ECONA_INVALID_POINTER
' // ECONA_INVALID_PARAMETER
' // ECONA_NOT_INITIALIZED
' // ECONA_UNKNOWN_ERROR
' //
Public Declare Function CONAGetDevices Lib "ConnAPI" (ByVal hDMHandle As Integer, ByRef iCount As Integer, ByVal pDevices As IntPtr) As Integer
' //=========================================================
' //=========================================================
' // CONAGetDevice
' //
' // Description:
' // Returns information about selected device
' //
' // Parameters:
' // hDMHandle [in] Device manager handle
' // pstrSerialNumber [in] Serial number of the device
' // pDevice [out] Pointer to device struct
' //
' // Return values:
' // CONA_OK
' // ECONA_INVALID_POINTER
' // ECONA_DEVICE_NOT_FOUND
' // ECONA_NOT_INITIALIZED
' // ECONA_UNKNOWN_ERROR
' //
Public Declare Function CONAGetDevice Lib "ConnAPI" (ByVal hDMHandle As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal pstrSerialNumber As String, ByVal pDevice As IntPtr) As Integer
' //=========================================================
' //=========================================================
' // CONAFreeDeviceStructure
' //
' // Description:
' // CONAFreeDeviceStructure release the memory, which
' // ConnectivitAPI is allocated inside CONAPI_DEVICE structs.
' //
' // Parameters:
' // iCount [in] Number of used CONAPI_DEVICE structs
' // pDevices [in] Pointer to CONAPI_DEVICE struct list
' //
' // Return values:
' // CONA_OK
' // ECONA_INVALID_POINTER
' // ECONA_INVALID_PARAMETER
' // ECONA_UNKNOWN_ERROR
' //
Public Declare Function CONAFreeDeviceStructure Lib "ConnAPI" (ByVal iCount As Integer, ByVal pDevices As IntPtr) As Integer
' //=========================================================
' //=========================================================
' // CONARefreshDeviceList
' //
' // Description:
' // Starts device list refreshing. All changes are notified throught the
' // notifications.
' //
' // Parameters:
' // hDMHandle [in] Device manager handle
' // iValue [in] Reserved for future use. Must be zero.
' //
' // Return values:
' // CONA_OK
' // ECONA_INVALID_PARAMETER
' // ECONA_NOT_INITIALIZED
' // ECONA_UNKNOWN_ERROR
Public Declare Function CONARefreshDeviceList Lib "ConnAPI" (ByVal hDMHandle As Integer, ByVal iValue As Integer) As Integer
' //=========================================================
' //=========================================================
' // CONARenameFriendlyName
' //
' // Description:
' // Sets a new friendly name for the device
' //
' // Parameters:
' // hDMHandle [in] Device manager handle
' // pstrSerialNumber [in] Serial number of the device.
' // pstrNewFriendlyName [in] New Device Friendly Name .
' //
' // Return values:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -