Exe'den EXE oluşturmak ve çalıştırmak.
14.10.2006 11:57
Senaryomuza göre Main.EXE'den Child.EXE i oluşturup çalıştıracağız.
Project -> Add Extisting Item diyerek Child.EXE yi projenize ekleyin.
Solution Explorer penceresinde Child.EXE yi seçin.
Properties penceresinde Build Action özelliğine Embeded Resource atayın.
Main.EXE de istediğiniz bir yerde aşağıdaki kodu çalıştırın :
System.Reflection.Assembly asm; byte
asm = System.Reflection.Assembly.GetExecutingAssembly();
string resourceName = asm.GetName().Name + ".Child.exe";
System.IO.Stream stream = asm.GetManifestResourceStream(resourceName);
int bufferSize = Convert.ToInt32(stream.Length);
stream.Read(buffer, 0, bufferSize);
string tempFileFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
string tempFilePath = System.IO.Path.Combine(tempFileFolder, "Child.exe");
System.IO.FileStream fs = new System.IO.FileStream(tempFilePath, System.IO.FileMode.Create);
fs.Write(buffer, 0, bufferSize);
fs.Close();
System.Diagnostics.Process.Start(tempFilePath); Doğal olarak Childe.EXE çalışırken bir güvenlik uyarı alıyorsunuz.
Bu yazı 2821 kere okundu.



