private void tsmiOpenFile_Click(object sender, EventArgs e) { if (lvApp.SelectedItems.Count < 1) { return; } foreach (ListViewItem lviTemp in lvApp.SelectedItems) { SoftwareInformation siTemp = ListViewUtil.GetSoftwareInformationOfList(lviTemp, Global.siMain); Process.Start("explorer.exe", siTemp.strFileLocation); } }
private void lvApp_SelectedIndexChanged(object sender, EventArgs e) { if (lvApp.SelectedItems.Count < 1) { return; } SoftwareInformation siTemp = ListViewUtil.GetSoftwareInformationOfList(lvApp.SelectedItems[0], Global.siMain); picAppIcon.Image = siTemp.imgLargeIcon; lblDisplayName.Text = siTemp.strDisplayName; lblPublisher.Text = siTemp.strPublisher; lblState.Text = "Selected " + lvApp.SelectedItems.Count.ToString() + " item" + (lvApp.SelectedItems.Count > 1 ? "s" : "") + "."; }
private void tsmiOpenReg_Click(object sender, EventArgs e) { if (lvApp.SelectedItems.Count < 1) { return; } foreach (ListViewItem lviTemp in lvApp.SelectedItems) { SoftwareInformation siTemp = ListViewUtil.GetSoftwareInformationOfList(lviTemp, Global.siMain); RegistryKey regkeyTemp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Applets\Regedit", true); regkeyTemp.SetValue("Lastkey", @"HKLM\" + siTemp.strRegistryLocation, RegistryValueKind.String); regkeyTemp.Close(); Process.Start("regedit.exe"); } }
private void UninstallSelectedItems() { if (lvApp.SelectedItems.Count < 1) { return; } foreach (ListViewItem lviTemp in lvApp.SelectedItems) { try { SoftwareInformation siTemp = ListViewUtil.GetSoftwareInformationOfList(lviTemp, Global.siMain); lblState.Text = "Uninstalling " + siTemp.strDisplayName + ".."; /* * int PID = Interaction.Shell(siTemp.strUninstallString, AppWinStyle.NormalFocus); * if(PID > 0) * { * Process proc = Process.GetProcessById(PID); * if (proc.HasExited) MessageBox.Show("asd"); * proc.EnableRaisingEvents = true; * proc.Exited += new EventHandler(Process_Exited); * // 이벤트 등록하기도 전에 이미 종료됨 * }*/ Process proc = new Process(); proc.StartInfo.FileName = siTemp.strUninstallString; proc.EnableRaisingEvents = true; proc.Exited += new EventHandler(Process_Exited); proc.Start(); //Console.WriteLine("시작 : " + proc.ProcessName); } catch { lblState.Text = "Failed to uninstall."; } } }
public int Compare(object x, object y) { dynamic Value_x = null; dynamic Value_y = null; // listview item to struct index SoftwareInformation siX = ListViewUtil.GetSoftwareInformationOfList((ListViewItem)x, Global.siMain); SoftwareInformation siY = ListViewUtil.GetSoftwareInformationOfList((ListViewItem)y, Global.siMain); // col name to struct info switch (ColumnName) { case "Name": // strDisplayName Value_x = siX.strDisplayName; Value_y = siY.strDisplayName; break; case "Publisher": // strPublisher Value_x = siX.strPublisher; Value_y = siY.strPublisher; break; case "Version": // strDisplayVersion Value_x = siX.strDisplayVersion; Value_y = siY.strDisplayVersion; break; case "Install Time": // dtLastWriteTime Value_x = siX.dtLastWriteTime; Value_y = siY.dtLastWriteTime; break; case "Size": // lngFileLocationSize Value_x = siX.lngFileLocationSize; Value_y = siY.lngFileLocationSize; break; case "Help Link": // strHelpLink Value_x = siX.strHelpLink; Value_y = siY.strHelpLink; break; case "Support Link": // strSupportLink Value_x = siX.strSupportLink; Value_y = siY.strSupportLink; break; case "File Location": // strFileLocation Value_x = siX.strFileLocation; Value_y = siY.strFileLocation; break; case "Registry Location": // strRegistryLocation Value_x = siX.strRegistryLocation; Value_y = siY.strRegistryLocation; break; } if (SortType == SortOrder.Ascending) // asc { if (Value_x is string || Value_x is null) { return(String.Compare((string)Value_x, (string)Value_y)); } else if (Value_x is DateTime) { return(DateTime.Compare((DateTime)Value_x, (DateTime)Value_y)); } else if (Value_x is long) { if (Value_x < Value_y) { return(-1); } else if (Value_x > Value_y) { return(1); } else { return(0); } } else { return(0); } } else if (SortType == SortOrder.Descending) // desc { if (Value_x is string || Value_x is null) { return(String.Compare((string)Value_y, (string)Value_x)); } else if (Value_x is DateTime) { return(DateTime.Compare((DateTime)Value_y, (DateTime)Value_x)); } else if (Value_x is long) { if (Value_x > Value_y) { return(-1); } else if (Value_x < Value_y) { return(1); } else { return(0); } } else { return(0); } } else { //MessageBox.Show("unknown sort type"); return(0); } }