Forum
Bildirimler
Hepsini Temizle
Yazılım Genel
2
Yazılar
2
Üyeler
0
Reactions
463
Görüntüleme
Konu başlatıcı
Aşagıdaki gibi C # yaptıgım uygulamayı bir türlü C++ a çeviremiyorum lütfen yardımcı olurmusunuz..
Teşekkürler:)
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Management;
using System.Diagnostics;
namespace Asetup
{
class Class1
{
private static readonly Class1 checker = new Class1();
public string antivirus, isletimsistemi;
string wmipathstr = "";
bool avcontrol = false; bool device = false;
string av, agent;
public void basla()
{
{
string line;
using (System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @"\config.ini"))
{
while (sr.Peek() > 0)
{
line = sr.ReadLine();
if (line == "antivirus:1")
av = "1";
else if (line == "antivirus:0")
av = "0";
if (line == "agent:1")
agent = "1";
else if (line == "agent:0")
agent = "0";
}
sr.Close();
}
using (System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @"\config.ini"))
{
while (sr.Peek() > 0)
{
line = sr.ReadLine();
if (line == "devicecontrol:1")
device = true;
else if (line == "devicecontrol:0")
device = false;
if (device == true)
{
if (line == "usb:1")
{
Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR", true).SetValue("Start", 3, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\StorageDevicePolicies");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\StorageDevicePolicies", true).SetValue("WriteProtect", 1, Microsoft.Win32.RegistryValueKind.DWord);
}
else if (line == "usb:3")
{
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\StorageDevicePolicies", true).DeleteValue("WriteProtect");
Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR", true).SetValue("Start", 3, Microsoft.Win32.RegistryValueKind.DWord);
}
else if (line == "usb:4")
{
//SYSTEM\CurrentControlSet\Services\USBSTOR
Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR", true).SetValue("Start", 4, Microsoft.Win32.RegistryValueKind.DWord);
}
}
else if (device == false)
if (line == "antiviruscontrol:1")
{
string wmipathstr2 = @"\\" + Environment.MachineName + @"\root\CIMV2";
var searcher2 = new ManagementObjectSearcher(wmipathstr2, "SELECT * FROM Win32_OperatingSystem");
foreach (var instances in searcher2.Get())
{
isletimsistemi = Convert.ToString(instances.GetPropertyValue("Caption"));
}
int a = isletimsistemi.IndexOf("Windows 7", 1);
int b = isletimsistemi.IndexOf("Vista", 1);
int c = isletimsistemi.IndexOf("XP", 1);
if ((a > -1) || (b > -1))
wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter2";
else if (c > -1)
wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter";
var searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct");
foreach (var instances in searcher.Get())
{
antivirus = Convert.ToString(instances.GetPropertyValue("displayName"));
}
if (antivirus == null)
{
asd(); goto bass;
}
else if (antivirus != null)
{
avcontrol = true;
islem(); goto bass;
}
}
if (line == "antiviruscontrol:0")
{
asd(); goto bass;
// MessageBox.Show("av control 0");
}
}
}
bass:
Form1 frm = new Form1();
}
}
public void islem()
{
string line;
Process p = new Process();
if (av == "1")
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @"\config.ini"))
{
while (sr.Peek() > 0)
{
line = sr.ReadLine();
if (line == "avuninstall:1")
{
if (avcontrol == true)
{
p.StartInfo.FileName = Application.StartupPath + "\\uninstall.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct");
string antivirus2 = "";
foreach (var instances in searcher.Get())
antivirus2 = Convert.ToString(instances.GetPropertyValue("displayName"));
if (antivirus2 != null)
MessageBox.Show("Sisteminizde \"" + antivirus2 + "\" bulundu fakat kaldırılamadı.", "Avira", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else if (antivirus2 == null)
{ asd(); }
}
}
else if (line == "avuninstall:0")
MessageBox.Show("Sisteminizde \"" + antivirus + "\" mevcut. İlgili antivirüsü kaldırıp tekrar deneyin.", "Avira", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
}
string FireWall;
public void asd()
{
string line;
Process p = new Process();
string zippath = Application.StartupPath;
if (av == "1")
{
p.StartInfo.FileName = Application.StartupPath + "\\7z.exe";
p.StartInfo.Arguments = "x -y \"" + zippath + "\\Av.zip\" -o\"" + zippath + "\\\" -pavira";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
using (System.IO.StreamReader rr = new System.IO.StreamReader(Application.StartupPath + @"\Av\setup.inf"))
{
while (rr.Peek() > 0)
{
line = rr.ReadLine();
if (line == "FireWall=1")
FireWall = "1";
else if (line == "FireWall=0")
FireWall = "0";
}
rr.Close();
}
}
if (agent == "1")
{
p.StartInfo.FileName = Application.StartupPath + "\\7z.exe";
p.StartInfo.Arguments = "x -y \"" + zippath + "\\AvAgent.zip\" -o\"" + zippath + "\\\"";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
if (av == "1" && FireWall == "1" && agent == "0")
{
p.StartInfo.FileName = Application.StartupPath + "\\Av\\presetup.exe";
p.StartInfo.Arguments = "/inf=\"" + Application.StartupPath + "\\Av\\setup.inf\"";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
if (av == "1" && FireWall == "0")
{
p.StartInfo.FileName = Application.StartupPath + "\\Av\\presetup.exe";
p.StartInfo.Arguments = "/inf=\"" + Application.StartupPath + "\\Av\\setup.inf\"";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
if (av == "1" && FireWall == "1")
{
if (agent == "1")
{
bool grouppullmode = false;
using (System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @"\config.ini"))
{
while (sr.Peek() > 0)
{
line = sr.ReadLine();
if (line == "grouppullmode:1")
grouppullmode = true;
else if (line == "grouppullmode:0")
grouppullmode = false;
else if (line == "restore:1")
{
p.StartInfo.FileName = Application.StartupPath + "\\uninstallagent.bat";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
else if (line.StartsWith("groupname"))
{
string groupname = line.Substring(10);
if (grouppullmode == true)
{
using (StreamReader reader = new StreamReader(Application.StartupPath + @"\Agent\installsmcagent.iss"))
{
using (StreamWriter writer = new StreamWriter(Application.StartupPath + @"\Agent\test.iss"))
{
while (reader.Peek() > 0)
{
string linee = reader.ReadLine();
if (linee.StartsWith("smcdisplayname"))
writer.WriteLine("smcdisplayname=" + groupname + "-" + System.Windows.Forms.SystemInformation.ComputerName);
else
writer.WriteLine(linee);
} writer.Close();
} reader.Close();
}
File.Delete(Application.StartupPath + @"\Agent\installsmcagent.iss");
File.Move(Application.StartupPath + @"\Agent\test.iss", Application.StartupPath + @"\Agent\installsmcagent.iss");
}
}
}
sr.Close();
p.StartInfo.FileName = Application.StartupPath + "\\Agent\\installagent.bat";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
p.StartInfo.FileName = Application.StartupPath + "\\Av\\presetup.exe";
p.StartInfo.Arguments = "/inf=\"" + Application.StartupPath + "\\Av\\setup.inf\"";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
}
if (agent == "1")
{
bool grouppullmode = false;
using (System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @"\config.ini"))
{
while (sr.Peek() > 0)
{
line = sr.ReadLine();
if (line == "grouppullmode:1")
grouppullmode = true;
else if (line == "grouppullmode:0")
grouppullmode = false;
else if (line == "restore:1")
{
p.StartInfo.FileName = Application.StartupPath + "\\uninstallagent.bat";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
else if (line.StartsWith("groupname"))
{
string groupname = line.Substring(10);
if (grouppullmode == true)
{
using (StreamReader reader = new StreamReader(Application.StartupPath + @"\Agent\installsmcagent.iss"))
{
using (StreamWriter writer = new StreamWriter(Application.StartupPath + @"\Agent\test.iss"))
{
while (reader.Peek() > 0)
{
string linee = reader.ReadLine();
if (linee.StartsWith("smcdisplayname"))
writer.WriteLine("smcdisplayname=" + groupname + "-" + System.Windows.Forms.SystemInformation.ComputerName);
else
writer.WriteLine(linee);
} writer.Close();
} reader.Close();
}
File.Delete(Application.StartupPath + @"\Agent\installsmcagent.iss");
File.Move(Application.StartupPath + @"\Agent\test.iss", Application.StartupPath + @"\Agent\installsmcagent.iss");
}
}
}
sr.Close();
p.StartInfo.FileName = Application.StartupPath + "\\Agent\\installagent.bat";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
using (System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @"\config.ini"))
{
while (sr.Peek() > 0)
{
line = sr.ReadLine();
if (line == "addremove:1")
{
p.StartInfo.FileName = Application.StartupPath + "\\agent_add_remove.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
}
}
sr.Close();
}
}
Application.Exit();
}
}
}
}
Gönderildi : 10/09/2012 01:51
"Çok acil" gibi ifadelerle konu başlığı açılamıyor. Başka bir başlıkta açtınız bu başlığı kilitliyorum.
Gönderildi : 11/09/2012 19:55