Click here to Skip to main content
15,905,010 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need the code for Randomization of numbers using c# Pin
Christian Graus4-Oct-09 22:07
protectorChristian Graus4-Oct-09 22:07 
GeneralRe: Need the code for Randomization of numbers using c# Pin
OriginalGriff4-Oct-09 22:13
mveOriginalGriff4-Oct-09 22:13 
GeneralRe: Need the code for Randomization of numbers using c# Pin
Christian Graus4-Oct-09 22:14
protectorChristian Graus4-Oct-09 22:14 
GeneralRe: Need the code for Randomization of numbers using c# Pin
Skymir5-Oct-09 2:50
Skymir5-Oct-09 2:50 
GeneralRe: Need the code for Randomization of numbers using c# Pin
Henry Minute5-Oct-09 3:40
Henry Minute5-Oct-09 3:40 
GeneralRe: Need the code for Randomization of numbers using c# Pin
OriginalGriff5-Oct-09 5:32
mveOriginalGriff5-Oct-09 5:32 
GeneralRe: Need the code for Randomization of numbers using c# Pin
vasavi.p4-Oct-09 22:11
vasavi.p4-Oct-09 22:11 
GeneralRe: Need the code for Randomization of numbers using c# Pin
Christian Graus4-Oct-09 22:13
protectorChristian Graus4-Oct-09 22:13 
GeneralRe: Need the code for Randomization of numbers using c# Pin
OriginalGriff4-Oct-09 22:14
mveOriginalGriff4-Oct-09 22:14 
JokeRe: Need the code for Randomization of numbers using c# Pin
Christian Graus4-Oct-09 22:21
protectorChristian Graus4-Oct-09 22:21 
JokeRe: Need the code for Randomization of numbers using c# Pin
OriginalGriff4-Oct-09 22:28
mveOriginalGriff4-Oct-09 22:28 
JokeRe: Need the code for Randomization of numbers using c# Pin
nagendrathecoder4-Oct-09 22:55
nagendrathecoder4-Oct-09 22:55 
GeneralRe: Need the code for Randomization of numbers using c# Pin
vasavi.p4-Oct-09 22:54
vasavi.p4-Oct-09 22:54 
GeneralRe: Need the code for Randomization of numbers using c# Pin
OriginalGriff4-Oct-09 23:01
mveOriginalGriff4-Oct-09 23:01 
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 

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.