Beispiel #1
0
        public static Process StartIE7ViaLaunchURL(string url)
        {
            TraceMsg("StartIE7ViaLaunchURL: {0}", new object[] { url });
            PROCESS_INFORMATION pProcInfo = new PROCESS_INFORMATION();
            IELAUNCHURLINFO     structure = new IELAUNCHURLINFO();

            structure.cbSize          = Marshal.SizeOf(structure);
            structure.dwCreationFlags = 0;
            int num = IELaunchURL(url, ref pProcInfo, ref structure);

            TraceMsg("IELaunchURL(): rc={0}: {1}", new object[] { num, (num != 0) ? "error" : "ok" });
            Process processById = Process.GetProcessById(GetProcessId(pProcInfo.hProcess));

            CloseHandle(pProcInfo.hThread);
            CloseHandle(pProcInfo.hProcess);
            return(processById);
        }
Beispiel #2
0
        private void startURLButton_Click(object sender, EventArgs e)
        {
            if (!CheckProcessTerminate() || !CheckFileSave())
                return;

            if (!noUI)
            {
                //URL+Desktop Runtime is a legal choice,
                //But more likely a careless mistake.
                if (!targetv4CoreCLR())
                {
                    DialogResult dr = MessageBox.Show("You are about to profile the desktop CLR on a web page.  This is likely a mistake.\nIf you would like to profile Silverlight, please press cancel and select \"V4 Core CLR\".",
                                                      "CLRProfiler", MessageBoxButtons.OKCancel);
                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                OpenURLForm openURLForm = new OpenURLForm();
                if (openURLForm.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                profilingURL = openURLForm.GetURL();
                if ((profilingURL == null) || (profilingURL == string.Empty))
                {
                    MessageBox.Show("URL is invalid.", "Failure");
                    return;
                }
            }

            try
            {
                if (targetv4CoreCLR())
                {
                    Environment.SetEnvironmentVariable("CoreCLR_Enable_Profiling", "0x1");
                    Environment.SetEnvironmentVariable("CORECLR_PROFILER", "{8C29BC4E-1F57-461a-9B51-1200C32E6F1F}");
                    Environment.SetEnvironmentVariable("CORECLR_PROFILER_PATH", getProfilerFullPath());
                }
                else
                {
                    Environment.SetEnvironmentVariable("Cor_Enable_Profiling", "0x1");
                    Environment.SetEnvironmentVariable("COR_PROFILER", "{8C29BC4E-1F57-461a-9B51-1200C32E6F1F}");
                    Environment.SetEnvironmentVariable("COR_PROFILER_PATH", getProfilerFullPath());
                }

                Environment.SetEnvironmentVariable("OMV_USAGE", CreateUsageString());
                Environment.SetEnvironmentVariable("OMV_SKIP", "0");
                Environment.SetEnvironmentVariable("OMV_PATH", GetLogDir());
                Environment.SetEnvironmentVariable("OMV_STACK", trackCallStacks ? "1" : "0");
                Environment.SetEnvironmentVariable("OMV_FORMAT", "v2");
                Environment.SetEnvironmentVariable("OMV_DynamicObjectTracking", "0x1");
                Environment.SetEnvironmentVariable("OMV_FORCE_GC_ON_COMMENT", gcOnLogFileComments ? "1" : "0");
                Environment.SetEnvironmentVariable("OMV_INITIAL_SETTING", CreateInitialString());
                Environment.SetEnvironmentVariable("OMV_TargetCLRVersion", targetv2DesktopCLR() ? "v2" : "v4");

                PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
                IELAUNCHURLINFO IEli = new IELAUNCHURLINFO();
                IEli.cbSize = Marshal.SizeOf(typeof(IELAUNCHURLINFO));
                if (IELaunchURL(profilingURL, ref pi, ref IEli) == 0)
                {
                    CloseHandle(pi.hProcess);
                    CloseHandle(pi.hThread);

                    profiledProcess = Process.GetProcessById((int)pi.dwProcessId);

                    if (WaitForProcessToConnect(GetLogDir(), "Waiting for application to start common language runtime") <= 0)
                        ClearProfiledProcessInfo();
                }
            }
            catch
            {
                processFileName = "iexplore.exe";
                commandLine = profilingURL;
                startApplicationButton_Click(null, null);
            }
            finally
            {
                if (targetv4CoreCLR())
                {
                    Environment.SetEnvironmentVariable("CoreCLR_Enable_Profiling", "");
                    Environment.SetEnvironmentVariable("CORECLR_PROFILER", "");
                    Environment.SetEnvironmentVariable("CORECLR_PROFILER_PATH", "");
                }
                else
                {
                    Environment.SetEnvironmentVariable("Cor_Enable_Profiling", "");
                    Environment.SetEnvironmentVariable("COR_PROFILER", "");
                    Environment.SetEnvironmentVariable("COR_PROFILER_PATH", "");
                }

                Environment.SetEnvironmentVariable("OMV_USAGE", "");
                Environment.SetEnvironmentVariable("OMV_SKIP", "");
                Environment.SetEnvironmentVariable("OMV_PATH", "");
                Environment.SetEnvironmentVariable("OMV_STACK", "");
                Environment.SetEnvironmentVariable("OMV_FORMAT", "");
                Environment.SetEnvironmentVariable("OMV_DynamicObjectTracking", "");
                Environment.SetEnvironmentVariable("OMV_FORCE_GC_ON_COMMENT", "");
                Environment.SetEnvironmentVariable("OMV_INITIAL_SETTING", "");
                Environment.SetEnvironmentVariable("OMV_TargetCLRVersion", "");
            }
        }
Beispiel #3
0
 public static extern int IELaunchURL([In] string pszUrl, ref PROCESS_INFORMATION pProcInfo, ref IELAUNCHURLINFO lpInfo);
Beispiel #4
0
 public static extern int IELaunchURL(
     [MarshalAs(UnmanagedType.LPWStr)] string url,
     ref PROCESS_INFORMATION pProcInfo,
     ref IELAUNCHURLINFO lpInfo);