private void button2_Click(object sender, EventArgs e) { string cmdInput; string cmdPre; int index; string item; string selectedText; string server; int index1; string item1; index = listBox2.SelectedIndex; item = listBox2.Items[index].ToString(); selectedText = item; index1 = listBox1.SelectedIndex; ; item1 = listBox1.Items[index1].ToString(); //Creates localprintserver where the queue's can be created on LocalPrintServer localPrintServer = new LocalPrintServer(); PrintQueueCollection myPrintQueues = localPrintServer.GetPrintQueues(); //Need to add the items to a string or array or something so i can check if printer exists foreach (PrintQueue pq in myPrintQueues) { // Add items variable } //string myPrintQueues = PrinterSettings.InstalledPrinters.ToString(); if (item1.Contains("Solution Worx - HQ")) { //string myPrintQueues = PrinterSettings.InstalledPrinters.ToString(); if (myPrintQueues.Contains(selectedText)) { server = @"\\srvswx.swxhq.local\"; cmdPre = @"RunDll32.EXE printui.dll,PrintUIEntry /dn /q /n " + server; cmdInput = selectedText; ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd", "/c " + cmdPre + cmdInput); Process process = Process.Start(processStartInfo); } else { MessageBox.Show("The print queue you have selected is not installed on your PC"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)