Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need the code for Randomization of numbers using c# Pin
Richard MacCutchan4-Oct-09 23:23
mveRichard MacCutchan4-Oct-09 23:23 
GeneralRe: Need the code for Randomization of numbers using c# Pin
J4amieC4-Oct-09 23:29
J4amieC4-Oct-09 23:29 
GeneralRe: Need the code for Randomization of numbers using c# Pin
Richard MacCutchan5-Oct-09 0:45
mveRichard MacCutchan5-Oct-09 0:45 
GeneralRe: Need the code for Randomization of numbers using c# Pin
J4amieC5-Oct-09 0:59
J4amieC5-Oct-09 0:59 
GeneralRe: Need the code for Randomization of numbers using c# Pin
Richard MacCutchan5-Oct-09 6:19
mveRichard MacCutchan5-Oct-09 6:19 
GeneralRe: Need the code for Randomization of numbers using c# Pin
J4amieC4-Oct-09 23:28
J4amieC4-Oct-09 23:28 
GeneralRe: Need the code for Randomization of numbers using c# Pin
DeepakMega4-Oct-09 23:33
DeepakMega4-Oct-09 23:33 
Questionform closing reason problem Pin
Ajithevn4-Oct-09 21:30
Ajithevn4-Oct-09 21:30 
Hi all
on form closing event i check if it is windows shutdown and if yes i uninstall the program it is not working for me.
i tried writting to a log file on form closing event if it is windows shutdown it worked.
from another application on ckick of a button also the uninstall program worked.
plz help me

private void ChatApplication_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.WindowsShutDown)
            {
                
                Uninstall();
                
            }            

        }

 private static void Uninstall()
        {
            Process oProcess = new Process();
            oProcess.StartInfo.FileName = "cmd.exe";
            oProcess.StartInfo.CreateNoWindow = true;
            oProcess.StartInfo.UseShellExecute = false;
            RegistryKey oRegKey = null;
            string sUninstallString = "";

            string[] asSubKeys = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\").GetSubKeyNames();
            foreach (string sSubKey in asSubKeys)
            {
                oRegKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + sSubKey);
                if (oRegKey.GetValue("Displayname") != null && oRegKey.GetValue("Displayname").ToString() == "Setup1")
                {
                    sUninstallString = oRegKey.GetValue("Uninstallstring").ToString();
                    break;
                }
            }

            if (sUninstallString.LastIndexOf("exe") != (sUninstallString.Length - 3))
            {
                sUninstallString = sUninstallString.Remove(0, 14);
                oProcess.StartInfo.Arguments = "/k msiexec.exe /x" + sUninstallString;
            }
            else
            {
                sUninstallString = sUninstallString.Replace("C:\\", "");
                string sExe = sUninstallString.Substring(sUninstallString.LastIndexOf('\\') + 1);
                sUninstallString = sUninstallString.Remove(sUninstallString.LastIndexOf('\\'));
                oProcess.StartInfo.Arguments = ("/k cd\\ & cd " + sUninstallString + " & " + sExe);
            }
            oProcess.StartInfo.RedirectStandardError = true;
            oProcess.Start();
            oProcess.WaitForExit();
            oProcess.Close();
            oProcess.Dispose();
        }

AnswerRe: form closing reason problem Pin
Christian Graus4-Oct-09 21:32
protectorChristian Graus4-Oct-09 21:32 
GeneralRe: form closing reason problem Pin
Ajithevn5-Oct-09 0:30
Ajithevn5-Oct-09 0:30 
Answer[Message Deleted] Pin
Blikkies4-Oct-09 21:50
professionalBlikkies4-Oct-09 21:50 
GeneralRe: form closing reason problem Pin
Ajithevn5-Oct-09 0:32
Ajithevn5-Oct-09 0:32 
GeneralRe: form closing reason problem Pin
Blikkies5-Oct-09 1:11
professionalBlikkies5-Oct-09 1:11 
AnswerRe: form closing reason problem Pin
Mycroft Holmes4-Oct-09 22:33
professionalMycroft Holmes4-Oct-09 22:33 
GeneralRe: form closing reason problem Pin
Ajithevn5-Oct-09 0:27
Ajithevn5-Oct-09 0:27 
Questionwhat is the problem in this >>> see the code and pls help me Pin
amaankhan4-Oct-09 21:06
amaankhan4-Oct-09 21:06 
AnswerRe: what is the problem in this >>> see the code and pls help me Pin
Christian Graus4-Oct-09 21:08
protectorChristian Graus4-Oct-09 21:08 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
amaankhan4-Oct-09 21:13
amaankhan4-Oct-09 21:13 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
Christian Graus4-Oct-09 21:23
protectorChristian Graus4-Oct-09 21:23 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
amaankhan4-Oct-09 21:32
amaankhan4-Oct-09 21:32 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
amaankhan4-Oct-09 21:37
amaankhan4-Oct-09 21:37 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
Christian Graus4-Oct-09 21:37
protectorChristian Graus4-Oct-09 21:37 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
amaankhan4-Oct-09 21:42
amaankhan4-Oct-09 21:42 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
Christian Graus4-Oct-09 22:17
protectorChristian Graus4-Oct-09 22:17 
GeneralRe: what is the problem in this >>> see the code and pls help me Pin
amaankhan4-Oct-09 22:20
amaankhan4-Oct-09 22:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.