📄 installerdialog.vb
字号:
End Sub
'===================================================================
' RefreshPhoneList
'
' Refresh phone list to combo
'
'===================================================================
Public Sub RefreshPhoneList()
On Error Resume Next
Dim i As Short
Dim iResult As Integer
Dim iCount As Integer
Dim buffer As IntPtr
Dim strCombo As String
Dim pDevices() As CONAPI_DEVICE
Dim itmX As MSComctlLib.ListItem
Timer1.Enabled = False
Me.ComboPhone.Items.Clear()
iResult = CONAGetDeviceCount(hDMHandle, iCount)
If iResult <> CONA_OK Then ShowErrorMessage("CONAGetDeviceCount", iResult)
If iResult = CONA_OK And iCount > 0 Then
ReDim pDevices(iCount)
ReDim strSerialNumbers(iCount)
' Allocate memory for buffer
buffer = Marshal.AllocHGlobal(iCount * Marshal.SizeOf(GetType(CONAPI_DEVICE)))
' Get list of currently connected devices
iResult = CONAGetDevices(hDMHandle, iCount, buffer)
If iResult <> CONA_OK Then
ShowErrorMessage("CONAGetDevices", iResult)
Else
' Add each device to the phone list box
For i = 0 To iCount - 1
' Calculate beginning of CONAPI_DEVICE structure of item 'i'
Dim iPtr As Int64 = buffer.ToInt64 + i * Marshal.SizeOf(GetType(CONAPI_DEVICE))
' Convert integer to pointer
Dim ptr As IntPtr = IntPtr.op_Explicit(iPtr)
' Copy data from buffer
pDevices(i) = Marshal.PtrToStructure(ptr, GetType(CONAPI_DEVICE))
' Add item to combo
strCombo = pDevices(i).pstrFriendlyName
Me.ComboPhone.Items.Add(strCombo)
strSerialNumbers(i) = pDevices(i).pstrSerialNumber
Next
Me.ComboPhone.Enabled = True
Me.ComboPhone.SelectedIndex = 0
' Free memory allocated by CONAGetDevices
iResult = CONAFreeDeviceStructure(iCount, buffer)
If iResult <> CONA_OK Then ShowErrorMessage("CONAFreeDeviceStructure", iResult)
End If
Marshal.FreeHGlobal(buffer)
Else
Me.ComboPhone.Text = "No phones connected"
Me.ComboPhone.Enabled = False
Me.ComboPhone.SelectedIndex = -1
End If
Timer1.Enabled = True
End Sub
'===================================================================
' TypeSelectionChanged
'
' User has changed installation type from combobox,
' so make some UI changes
'
'===================================================================
Private Sub TypeSelectionChanged()
TextJar.Text = ""
TextJad.Text = ""
TextSis.Text = ""
TextNth.Text = ""
TextJad.Enabled = False
TextJar.Enabled = False
TextSis.Enabled = False
TextNth.Enabled = False
TextNGage.Enabled = False
CommandJar.Enabled = False
CommandJad.Enabled = False
CommandSis.Enabled = False
CommandNth.Enabled = False
CommandNGage.Enabled = False
Dim strItem As String = ComboType.SelectedItem.ToString
If strItem = strJavaItem Then
iInstallationType = INSTALL_TYPE_JAVA
ElseIf strItem = strSymbianItem Then
iInstallationType = INSTALL_TYPE_SYMBIAN
ElseIf strItem = strThemesItem Then
iInstallationType = INSTALL_TYPE_THEMES
ElseIf strItem = strNGageItem Then
iInstallationType = INSTALL_TYPE_NGAGE
End If
If iInstallationType = INSTALL_TYPE_JAVA Then
TextJad.Enabled = True
TextJar.Enabled = True
CommandJar.Enabled = True
CommandJad.Enabled = True
ElseIf iInstallationType = INSTALL_TYPE_NGAGE Then
TextNGage.Enabled = True
CommandNGage.Enabled = True
ElseIf iInstallationType = INSTALL_TYPE_SYMBIAN Then
TextSis.Enabled = True
CommandSis.Enabled = True
ElseIf iInstallationType = INSTALL_TYPE_THEMES Then
TextNth.Enabled = True
CommandNth.Enabled = True
End If
End Sub
'===================================================================
' SetProgress
'
' Sets progress bar state
'
'===================================================================
Public Sub SetProgress(ByVal iState As Integer)
ProgressBar1.Value = iState
End Sub
'===================================================================
' IsCancelled
'
' Returns true if user has clicked Cancel button
'
'===================================================================
Public Function IsCancelled() As Boolean
Application.DoEvents()
IsCancelled = bCancelled
bCancelled = False
End Function
'===================================================================
' UninitializePCCAPI
'
' Uninitialize Nokia PC Connectivity API
'
'===================================================================
Private Sub UninitializePCCAPI()
On Error Resume Next
Dim iResult As Integer
' Unregister device notification callback function
iResult = CONARegisterNotifyCallback(hDMHandle, API_UNREGISTER, pDeviceCallBack)
If iResult <> CONA_OK Then ShowErrorMessage("CONARegisterNotifyCallback", iResult)
' Close device management handle
iResult = CONACloseDM(hDMHandle)
If iResult <> CONA_OK Then ShowErrorMessage("CONACloseDM", iResult)
' Uninitialize Nokia PC Connectivity API
' Terminate File System API
iResult = FSAPI_Terminate(0)
If iResult <> CONA_OK Then ShowErrorMessage("FSAPI_Terminate", iResult)
' Terminate Device Management APi
iResult = DMAPI_Terminate(0)
If iResult <> CONA_OK Then ShowErrorMessage("DMAPI_Terminate", iResult)
Application.Exit()
End Sub
'===================================================================
' InstallerDialog_Load
'
' Initialization of InstallerDialog form
'
'===================================================================
Private Sub InstallerDialog_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim iResult As Integer
' Dim col1 As MSComctlLib.ColumnHeader
' Dim col2 As MSComctlLib.ColumnHeader
' Dim col3 As MSComctlLib.ColumnHeader
MainForm = Me
bCancelled = False
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100
ProgressBar1.Value = 0
' Initialize Nokia PC Connectivity API
' Initialize Device Management APi
iResult = DMAPI_Initialize(DMAPI_VERSION_32, vbNullString)
If iResult <> CONA_OK Then ShowErrorMessage("DMAPI_Initialize", iResult)
' Initialize File System APi
iResult = FSAPI_Initialize(FSAPI_VERSION_32, vbNullString)
If iResult <> CONA_OK Then ShowErrorMessage("FSAPI_Initialize", iResult)
' Get Device management handle
iResult = CONAOpenDM(hDMHandle)
If iResult <> CONA_OK Then ShowErrorMessage("CONAOpenDM", iResult)
' Register device notification callback function
pDeviceCallBack = AddressOf DeviceNotifyCallback
iResult = CONARegisterNotifyCallback(hDMHandle, API_REGISTER, pDeviceCallBack)
If iResult <> CONA_OK Then ShowErrorMessage("CONARegisterNotifyCallback", iResult)
' Get connected devices list
Timer1.Enabled = True
Timer1.Start()
'Refresh phonelist
bRefreshPhonecombo = True
End Sub
'===================================================================
' ComboType_SelectedIndexChanged
'
' User has changed installation type from combobox
'
'===================================================================
Private Sub ComboType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboType.SelectedIndexChanged
TypeSelectionChanged()
End Sub
'=========================================================
' CommandJar_Click
'
' Opens file open dialog for selecting a file
'
'=========================================================
Private Sub CommandJar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandJar.Click
Dim openFileDialog As OpenFileDialog
openFileDialog = New OpenFileDialog
openFileDialog.Filter = "Jar files (*.jar)|*.jar"
openFileDialog.FilterIndex = 0
openFileDialog.RestoreDirectory = True
If openFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
TextJar.Text = openFileDialog.FileName
End If
End Sub
'=========================================================
' CommandJad_Click
'
' Opens file open dialog for selecting a file
'
'=========================================================
Private Sub CommandJad_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CommandJad.Click
Dim openFileDialog As OpenFileDialog
openFileDialog = New OpenFileDialog
openFileDialog.Filter = "Jad files (*.jad)|*.jad"
openFileDialog.FilterIndex = 0
openFileDialog.RestoreDirectory = True
If openFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
TextJad.Text = openFileDialog.FileName
End If
End Sub
'=========================================================
' CommandSis_Click
'
' Opens file open dialog for selecting a file
'
'=========================================================
Private Sub CommandSis_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CommandSis.Click
Dim openFileDialog As OpenFileDialog
openFileDialog = New OpenFileDialog
If bPhoneSupportsSisX Then
openFileDialog.Filter = "Sis files (*.sis)|*.sis|Sisx files (*.sisx)|*.sisx"
Else
openFileDialog.Filter = "Sis files (*.sis)|*.sis"
End If
openFileDialog.FilterIndex = 0
openFileDialog.RestoreDirectory = True
If openFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
TextSis.Text = openFileDialog.FileName
End If
End Sub
'=========================================================
' CommandNGage_Click
'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -