Hi.
Mittlerweile enthält meine Source keine MySQL - Zugangsadaten mehr, ich kann sie hier also reinposten. Das ist das Ergebnis nächtelanger Arbeit, ihc beschäftige mich erst seid 3 Wochen mit dieser Sprache und mir gehts es NOCH nicht um Schönheitsfehler wie Variablennamen, Invoke (gibt ja diese Einstellung) und son Zeug.
Spoiler anzeigen
Das ist meine Source. Kann mir bitte jemand sagen, warum das Programm während es nach Updates sucht einfriert (nur die UI) und nicht die Marquee - Bar anzeigt? (Ist doch schon ein neuer Thread)
Danke im Voraus für eure Hilfe!
Mittlerweile enthält meine Source keine MySQL - Zugangsadaten mehr, ich kann sie hier also reinposten. Das ist das Ergebnis nächtelanger Arbeit, ihc beschäftige mich erst seid 3 Wochen mit dieser Sprache und mir gehts es NOCH nicht um Schönheitsfehler wie Variablennamen, Invoke (gibt ja diese Einstellung) und son Zeug.
C#-Quellcode
- using Microsoft.Win32;
- using MySql.Data.MySqlClient;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void connect()
- {
- }
- private void read(string dn, List<string> dp, List<string> dns, List<string> ver, List<string> link, List<string> updnec, List<string> dv, string bitos, string dnsss, string updnecls)
- {
- NameValueCollection myNameValueCollection = new NameValueCollection();
- WebClient myWebClient = new WebClient();
- string response = string.Empty;
- bool prgAcc = new bool();
- if (Environment.Is64BitOperatingSystem == true)
- {
- if (dnsss.Contains("Wow6432Node"))
- {
- bitos = "x86";
- }
- else
- {
- bitos = "x64";
- }
- }
- else
- {
- bitos = "x86";
- }
- myNameValueCollection.Add("dn", dn + " " + bitos);
- //MessageBox.Show(bitos);
- byte[] responseArray = myWebClient.UploadValues("http://comptalk.de/cms/iup/version.php", "POST", myNameValueCollection);
- response=Encoding.ASCII.GetString(responseArray);
- if (response != null)
- {
- ver.Add(response);
- foreach (string dvss in dv)
- {
- //MessageBox.Show("Wichtig:" + dvss);
- int dvsss = int.Parse(dvss.Replace(".", ""));
- int dvsssss = int.Parse(response.Replace(".", ""));
- if (dvsss < dvsssss)
- {
- updnec.Add(dn);
- prgAcc = true;
- //MessageBox.Show("Zu UpdateNec wurde hinzugefügt:" + dvsss.ToString() + "<" + dvsssss.ToString());
- }
- else{
- prgAcc = false;
- //MessageBox.Show("Zu UpdateNec wurde nicht hinzugefügt:" + dvsss.ToString() + "<" + dvsssss.ToString());
- }
- }
- }
- responseArray = myWebClient.UploadValues("http://comptalk.de/cms/iup/link.php", "POST", myNameValueCollection);
- string linkresponse=Encoding.ASCII.GetString(responseArray);
- if (linkresponse != null)
- {
- if (prgAcc == true)
- {
- link.Add(linkresponse);
- }
- }
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void label3_Click(object sender, EventArgs e)
- {
- }
- private void label5_Click(object sender, EventArgs e)
- {
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void label8_Click(object sender, EventArgs e)
- {
- }
- private void progressBar1_Click(object sender, EventArgs e)
- {
- }
- private void button3_Click(object sender, EventArgs e)
- {
- //connect();
- CheckForIllegalCrossThreadCalls = false;
- WebClient myWebClient = new WebClient();
- string updnecls = string.Empty;
- string bitos = string.Empty;
- List<string> dp = new List<string>();
- RegistryKey localKey =
- RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine,
- RegistryView.Registry64);
- localKey = localKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player");
- if (Environment.Is64BitOperatingSystem == true)
- {
- if (localKey != null)
- {
- //MessageBox.Show("Found");
- if (localKey.GetValue("DisplayName") != null)
- {
- dp.Add(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player");
- }
- }
- else
- {
- dp.Add(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player");
- }
- }
- else
- {
- dp.Add(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player");
- }
- localKey =
- RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine,
- RegistryView.Registry64);
- localKey = localKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeamSpeak 3 Client");
- if (Environment.Is64BitOperatingSystem == true)
- {
- if (localKey != null)
- {
- //MessageBox.Show("Found");
- if (localKey.GetValue("DisplayName") != null)
- {
- dp.Add(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeamSpeak 3 Client");
- }
- }
- else
- {
- dp.Add(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\TeamSpeak 3 Client");
- }
- }
- else
- {
- dp.Add(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\TeamSpeak 3 Client");
- }
- localKey =
- RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine,
- RegistryView.Registry64);
- localKey = localKey.OpenSubKey(@"SOFTWARE\Wow6432Node\Reditec\iUP");
- if (Environment.Is64BitOperatingSystem == true)
- {
- if (localKey != null)
- {
- //MessageBox.Show("Found");
- if (localKey.GetValue("DisplayName") != null)
- {
- dp.Add(@"SOFTWARE\Wow6432Node\Reditec\iUP");
- }
- }
- else
- {
- dp.Add(@"SOFTWARE\Reditec\iUP");
- }
- }
- else
- {
- dp.Add(@"SOFTWARE\Reditec\iUP");
- }
- dp.Add(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner");
- List<string> dv = new List<string>();
- List<string> fnstr = new List<string>();
- List<string> updnec = new List<string>();
- List<string> dns = new List<string>();
- List<string> ver = new List<string>();
- List<string> link = new List<string>();
- foreach (string dnss in dp)
- {
- //MessageBox.Show(dnss);
- dv.Clear();
- string dn = string.Empty;
- localKey =
- RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine,
- RegistryView.Registry64);
- localKey = localKey.OpenSubKey(@dnss);
- if (localKey != null)
- {
- //MessageBox.Show("Found");
- if (localKey.GetValue("DisplayName") != null)
- {
- (new System.Threading.Thread(() =>
- {
- progressBar1.Style = ProgressBarStyle.Marquee;
- })).Start();
- dn = localKey.GetValue("DisplayName").ToString();
- dn = Regex.Replace(dn, @"[0-9\-]", string.Empty);
- dn = Regex.Replace(dn, @"[.\-]", string.Empty);
- dn = dn.Replace("VLC media player ", "VLC media player");
- //MessageBox.Show(dn +"!");
- dns.Add(localKey.GetValue("DisplayName").ToString());
- dv.Add(localKey.GetValue("DisplayVersion").ToString());
- read(dn, dp, dns, ver, link, updnec, dv, bitos, dnss, updnecls);
- }
- }
- //MessageBox.Show(String.Format(dn));
- }
- String ct = updnec.Count().ToString();
- //MessageBox.Show("Und jetzt der wichtige Scheiß:");
- foreach (string dvs in dv)
- {
- //MessageBox.Show(dvs);
- }
- int maxmm = new int();
- maxmm = link.Count();
- WebClient client = new WebClient();
- label10.Text = ct;
- label11.Text = System.DateTime.Now.ToString();
- progressBar1.Style = ProgressBarStyle.Blocks;
- System.IO.Directory.CreateDirectory("tmp");
- button3.Enabled = false;
- progressBar1.Style = ProgressBarStyle.Blocks;
- (new System.Threading.Thread(() =>
- {
- int mmn = 0;
- int mmx = link.Count();
- label6.Text = "0/" + mmx;
- (new System.Threading.Thread(() =>
- {
- progressBar1.Maximum = 1;
- progressBar1.Value = 0;
- })).Start();
- int vochar = link.Count();
- //MessageBox.Show(vochar.ToString());
- foreach (string lz in link)
- {
- label5.Text = updnec[mmn];
- Uri u = new Uri(lz);
- string filename = string.Empty;
- filename = Path.GetFileName(u.AbsolutePath);
- fnstr.Add(filename);
- client.DownloadFile(u, "tmp/" + filename);
- mmn = mmn + 1;
- label6.Text = mmn + "/" + mmx;
- (new System.Threading.Thread(() =>
- {
- progressBar1.Maximum = maxmm;
- progressBar1.Increment(1);
- })).Start();
- }
- updnec.Clear();
- (new System.Threading.Thread(() =>
- {
- progressBar1.Value = 0;
- })).Start();
- mmn = 0;
- label7.Text = mmn + "/" + maxmm;
- foreach (string gj in fnstr)
- {
- Process p = new Process();
- p.StartInfo.FileName = gj;
- p.StartInfo.WorkingDirectory = "tmp";
- p.StartInfo.UseShellExecute = true;
- if (gj.Contains("iUP-Updater"))
- {
- p.StartInfo.Arguments = "/qn";
- }
- else
- {
- p.StartInfo.Arguments = "/S";
- }
- p.Start();
- p.WaitForExit();
- (new System.Threading.Thread(() =>
- {
- progressBar1.Maximum = maxmm;
- progressBar1.Increment(1);
- label7.Text = mmn + "/" + maxmm;
- })).Start();
- mmn = mmn + 1;
- //button3.Enabled = true;
- (new System.Threading.Thread(() =>
- {
- progressBar1.Value = 0;
- progressBar1.Style = ProgressBarStyle.Blocks;
- })).Start();
- }
- if (updnec.Count() == 0)
- {
- button3.Enabled = true;
- progressBar1.Value = 0;
- (new System.Threading.Thread(() =>
- {
- progressBar1.Style = ProgressBarStyle.Blocks;
- })).Start();
- }
- })).Start();
- }
- void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- }
- private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
- {
- }
- private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- //progressBar1.Maximum = TotalBytesToReceive;
- ////progressBar1.Value = BytesReceived;
- //string sysload = progressBar1.Value / 1000000 + "/" + progressBar1.Maximum / 1000000 + " MB geladen";
- //label12.Text = sysload;
- }
- private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- }
- private void label13_Click(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Form2 newForm2 = new Form2();
- newForm2.ShowDialog();
- }
- }
- }
Das ist meine Source. Kann mir bitte jemand sagen, warum das Programm während es nach Updates sucht einfriert (nur die UI) und nicht die Marquee - Bar anzeigt? (Ist doch schon ein neuer Thread)
Danke im Voraus für eure Hilfe!