使用process.start(new processstartinfo(url))来打开某一网址的时候,往往会被360提示 类似这样的 信息:

“威胁:修改此注册表项将更改ie连接设置。少数软件会修改此项,如果随意修改,可能造成无法上网。如果您不认识此程序,请阻止。”

这是由于 360 会判断启动浏览器的父窗口,如果父窗口是系统或受信程序则通过,反之,若是未知的程序 则 提示威胁。

 

了解了这个,我们就可以想到 用 api函数 shellexecute,通过指定 父窗口参数为 null(0)来避免360提示。如下:

        [dllimport("shell32.dll")]
        public extern static intptr shellexecute(int hwnd,string lpoperation,string lpfile,string lpparameters,string lpdirectory,int nshowcmd);
        public enum showwindowcommands : int
        {
            sw_hide = 0,
            sw_shownormal = 1,
            sw_normal = 1,
            sw_showminimized = 2,
            sw_showmaximized = 3,
            sw_maximize = 3,
            sw_shownoactivate = 4,
            sw_show = 5,
            sw_minimize = 6,
            sw_showminnoactive = 7,
            sw_showna = 8,
            sw_restore = 9,
            sw_showdefault = 10,
            sw_max = 10
        }
        shellexecute(0, @"open",@"http://www.baidu.com", null, null, (int)showwindowcommands.sw_normal);

附上 shellexecute的 一些参考信息:
1.函数功能:
你可以给它任何文件的名字,它都能识别出来并打开它。
2.函数原型:
hinstance shellexecute(
                           hwnd hwnd,
                           lpctstr lpoperation,
                           lpctstr lpfile,
                           lpctstr lpparameters,
                           lpctstr lpdirectory,
                           int nshowcmd
);  
3.参数说明:
hwnd:
用于指定父窗口句柄。当函数调用过程出现错误时,它将作为windows消息窗口的父窗口。
lpoperation:
用于指定要进行的操作。
“open”操作表示执行由lpfile参数指定的程序,或打开由lpfile参数指定的文件或文件夹;
“print”操作表示打印由lpfile参数指定的文件;
“explore”操作表示浏览由lpfile参数指定的文件夹。
当参数设为null时,表示执行默认操作“open”。  
lpfile:
用于指定要打开的文件名、要执行的程序文件名或要浏览的文件夹名。
lpparameters:
若lpfile参数是一个可执行程序,则此参数指定命令行参数,否则此参数应为null.
lpdirectory:
用于指定默认目录.
nshowcmd:
若lpfile参数是一个可执行程序,则此参数指定程序窗口的初始显示方式,否则此参数应设置为0。
这个参数常用的常数:
sw_hide 隐藏窗口,活动状态给令一个窗口
sw_minimize 最小化窗口,活动状态给令一个窗口
sw_restore 用原来的大小和位置显示一个窗口,同时令其进入活动状态
sw_show 用当前的大小和位置显示一个窗口,同时令其进入活动状态
sw_showmaximized 最大化窗口,并将其激活
sw_showminimized 最小化窗口,并将其激活
sw_showminnoactive 最小化一个窗口,同时不改变活动窗口
sw_showna 用当前的大小和位置显示一个窗口,不改变活动窗口
sw_shownoactivate 用最近的大小和位置显示一个窗口,同时不改变活动窗口
sw_shownormal 与sw_restore相同
若shellexecute函数调用成功,则返回值为被执行程序的实例句柄。若返回值小于32,则表示出现错误。  

4.返回值

执行成功会返回应用程序句柄

返回的hinstance可以将它转换为一个整数(%d),并比较它的值大于还是小于32或比较它的错误代码
返回值大于32表示执行成功
返回值小于32表示执行错误

msdn:if the function succeeds, it returns a value greater than 32. if the function fails, it returns an error value that indicates the cause of the failure. the return value is cast as an hinstance for backward compatibility with 16-bit windows applications. it is not a true hinstance, however. it can be cast only to an int and compared to either 32 or the following error codes below.

返回值可能的错误有: = 0 {内存不足}

error_file_not_found = 2; {文件名错误}

error_path_not_found = 3; {路径名错误}

error_bad_format = 11; {exe 文件无效}

se_err_share = 26; {发生共享错误}

se_err_associncomplete = 27; {文件名不完全或无效}

se_err_ddetimeout = 28; {超时}

se_err_ddefail = 29; {dde 事务失败}

se_err_ddebusy = 30; {正在处理其他 dde 事务而不能完成该 dde 事务}

se_err_noassoc = 31; {没有相关联的应用程序}

5.使用方法:
例如:
    shellexecute(null,”open”,”iloveu.bmp”,null,null,sw_shownormal);      
用缺省的位图编辑器打开一个叫iloveu.bmp的位图文件,这个缺省的位图编辑器可能是 microsoft paint, adobe photoshop, 或者 corel photopaint。
    这个函数能打开任何文件,甚至是桌面和url快捷方式( .ink或 .url)。shellexecute解析系统注册表hkey_classes_root中所有的内容,判断启动那一个执行程序,并且启动一个新的实例或使用dde将文件名连到一打开的实例。然后,shellexecute 返回打开文件的应用的实例句柄。
shellexecute(null, “open”, “http://www.microsoft.com”, null, null, sw_shownormal); 
    这个代码使你能访问微软的主页。当shellexecute遇到文件名前面的“http:”时,可以判断出要打开的文件是web文件,随之启动internet explorer 或者 netscape navigator 或者任何你使用的别的浏览器打开文件。
shellexecute还能识别其它协议,象ftp、gopher。甚至识别“mailto”,如果文件名指向“mailto:zxn@hq.cninfo.net”,它启动电子邮件程序并打开一个待编辑的新邮件,例如:
    shellexecute(null, “open”,“mailto:zxn@hq.cninfo.net”, null, null, sw_shownormal);打开新邮件窗口。
    总之,shellexecute函数就是如此简单地打开磁盘文件和internet文件。如果将第二个参数“open”改为“print”或者“explore”,shellexecute将能打印文件和打开文件夹。shellexecute还有一个扩展函数shellexecuteex,所带参数中有一个特殊的结构,功能更强,或者任何你使用的别的浏览器打开文件。

———————————————————————————— 
原文:https://blog.csdn.net/snakorse/article/details/20035437