• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ Programmer's Cookbook

            {C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

            分別用c++,c#,vb script 來打開www.baidu.com

            使用c++:

            (下面是傳遞參數的結構)

            typedef struct _SHELLEXECUTEINFO {
                DWORD cbSize;
                ULONG fMask;
                HWND hwnd;
                LPCTSTR lpVerb;
                LPCTSTR lpFile;
                LPCTSTR lpParameters;
                LPCTSTR lpDirectory;
                
            int  nShow;
                HINSTANCE hInstApp;
                LPVOID lpIDList;
                LPCTSTR lpClass;
                HKEY hkeyClass;
                DWORD dwHotKey;
                union {
                    HANDLE hIcon;
                    HANDLE hMonitor;
                } DUMMYUNIONNAME;
                HANDLE hProcess;
            } SHELLEXECUTEINFO, 
            * LPSHELLEXECUTEINFO;

            (打開實例)

            #include  < windows.h >
            #include 
            < shellapi.h >
            #include 
            < stdio.h >

            int  main( int  argc, char *  argv[])
            {

                SHELLEXECUTEINFO shell 
            =  { sizeof(shell) };
                shell.fMask 
            =  SEE_MASK_FLAG_DDEWAIT;
                shell.lpVerb 
            =   " open " ;
                shell.lpFile 
            =   " IEXPLORE.EXE " ;
                shell.lpParameters 
            =   " http://www.baidu.com " ;
                shell.nShow 
            =  SW_SHOWNORMAL;
                BOOL ret 
            =  ShellExecuteEx( & shell);  
               
                return 
            0 ;
            }

            使用c#:
            (參數ProcessStartInfo ,參看msdn)
            (使用實例 :只有在STA線程上ShellExecute 才能確保工作無誤。在Process的實現中,并沒有考慮到這個問題,所以使用Process類運行ShellExecute可能會出錯。如果你不能保證調用Process.Start的線程的ApartmentState,可以使用如下的代碼來避免這個問題:

            using System;

            using System.Threading;

            public class Foo
            {

                
            public static void OpenUrl()
                {

                    System.Diagnostics.Process.Start(@
            "http://www.baidu.com");

                }

                
            public static void Main()
                {

                    ThreadStart openUrlDelegate 
            = new ThreadStart(Foo.OpenUrl);

                    Thread myThread 
            = new Thread(openUrlDelegate);

                    myThread.SetApartmentState(ApartmentState.STA);

                    myThread.Start();

                    myThread.Join();

                }

            }



            使用windows腳本:
            javascript:

            // Create Internet Explorer Object
            //
            InternetExplorer.Application 運行IE瀏覽器
            ie = new ActiveXObject("InternetExplorer.Application");

            //var ie=wscript.createobject("internetexplorer.application","event_");
            //
             Define how the window should look

            ie.left
            =-5;
            ie.top
            =-25;
            ie.height
            =860;//高度
            ie.width=1035;//寬度
            ie.menubar=0;//取消菜單欄
            ie.addressbar=0;//取消地址欄
            ie.toolbar=0;//取消工具欄
            ie.statusbar=0;//取消狀態欄
            ie.resizable=0;//不允許用戶改變窗口大小
            ie.visible=1;//窗口可見
            ie.navigate("http://www.baidu.com")
            //打開窗口




            VBScript:

            Dim objIE 
            Set objIE = WScript.CreateObject ("InternetExplorer.Application"
            objIE.AddressBar 
            = true 
            objIE.Visible 
            = true 
            objIE.Navigate(
            "www.baidu.com")



            參考:
            http://blogs.msdn.com/oldnewthing/archive/2004/11/26/270710.aspx

            http://blog.joycode.com/gangp/archive/2004/08/14/30668.aspx


            附錄:(來自msdn)
            c#:

            using System;
            using System.Diagnostics;
            using System.ComponentModel;

            namespace MyProcessSample
            {
                
            /// <summary>
                
            /// Shell for the sample.
                
            /// </summary>

                class MyProcess
                
            {
                   
                    
            /// <summary>
                    
            /// Opens the Internet Explorer application.
                    
            /// </summary>

                    void OpenApplication(string myFavoritesPath)
                    
            {
                        
            // Start Internet Explorer. Defaults to the home page.
                        Process.Start("IExplore.exe");
                                
                        
            // Display the contents of the favorites folder in the browser.
                        Process.Start(myFavoritesPath);
             
                    }

                    
                    
            /// <summary>
                    
            /// Opens urls and .html documents using Internet Explorer.
                    
            /// </summary>

                    void OpenWithArguments()
                    
            {
                        
            // url's are not considered documents. They can only be opened
                        
            // by passing them as arguments.
                        Process.Start("IExplore.exe""www.northwindtraders.com");
                        
                        
            // Start a Web page using a browser associated with .html and .asp files.
                        Process.Start("IExplore.exe""C:\\myPath\\myFile.htm");
                        Process.Start(
            "IExplore.exe""C:\\myPath\\myFile.asp");
                    }

                    
                    
            /// <summary>
                    
            /// Uses the ProcessStartInfo class to start new processes, both in a minimized 
                    
            /// mode.
                    
            /// </summary>

                    void OpenWithStartInfo()
                    
            {
                        
                        ProcessStartInfo startInfo 
            = new ProcessStartInfo("IExplore.exe");
                        startInfo.WindowStyle 
            = ProcessWindowStyle.Minimized;
                        
                        Process.Start(startInfo);
                        
                        startInfo.Arguments 
            = "www.northwindtraders.com";
                        
                        Process.Start(startInfo);
                        
                    }


                    
            static void Main()
                    
            {
                                
            // Get the path that stores favorite links.
                                string myFavoritesPath = 
                                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
                            
                                MyProcess myProcess 
            = new MyProcess();
                     
                        myProcess.OpenApplication(myFavoritesPath);
                        myProcess.OpenWithArguments();
                        myProcess.OpenWithStartInfo();

                           }
                
                }

            }


            CLI/C++:
            #using <System.dll>

            using namespace System;
            using namespace System::Diagnostics;
            using namespace System::ComponentModel;

            /// <summary>
            /// Opens the Internet Explorer application.
            /// </summary>

            void OpenApplication( String^ myFavoritesPath )
            {
               
               
            // Start Internet Explorer. Defaults to the home page.
               Process::Start( "IExplore.exe" );
               
               
            // Display the contents of the favorites folder in the browser.
               Process::Start( myFavoritesPath );
            }



            /// <summary>
            /// Opens urls and .html documents using Internet Explorer.
            /// </summary>

            void OpenWithArguments()
            {
               
               
            // url's are not considered documents. They can only be opened
               
            // by passing them as arguments.
               Process::Start( "IExplore.exe""www.northwindtraders.com" );
               
               
            // Start a Web page using a browser associated with .html and .asp files.
               Process::Start( "IExplore.exe""C:\\myPath\\myFile.htm" );
               Process::Start( 
            "IExplore.exe""C:\\myPath\\myFile.asp" );
            }



            /// <summary>
            /// Uses the ProcessStartInfo class to start new processes, both in a minimized 
            /// mode.
            /// </summary>

            void OpenWithStartInfo()
            {
               ProcessStartInfo
            ^ startInfo = gcnew ProcessStartInfo( "IExplore.exe" );
               startInfo
            ->WindowStyle = ProcessWindowStyle::Minimized;
               Process::Start( startInfo );
               startInfo
            ->Arguments = "www.northwindtraders.com";
               Process::Start( startInfo );
            }


            int main()
            {
               
               
            // Get the path that stores favorite links.
               String^ myFavoritesPath = Environment::GetFolderPath( Environment::SpecialFolder::Favorites );
               OpenApplication( myFavoritesPath );
               OpenWithArguments();
               OpenWithStartInfo();
            }

            posted on 2006-09-27 15:59 夢在天涯 閱讀(3606) 評論(3)  編輯 收藏 引用 所屬分類: CPlusPlusC#/.NETWindows Script

            評論

            # re: 分別用c++,c#,vb script 來打開www.baidu.com 2007-06-25 21:39 永勝

            我要勁舞  回復  更多評論   

            # re: 分別用c++,c#,vb script 來打開www.baidu.com 2007-06-25 21:40 永勝

            WOAI NI   回復  更多評論   

            # re: 分別用c++,c#,vb script 來打開www.baidu.com 2012-10-25 10:27 吾要茶坊

            分別用c++,c#,是什么意思?  回復  更多評論   

            公告

            EMail:itech001#126.com

            導航

            統計

            • 隨筆 - 461
            • 文章 - 4
            • 評論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1804603
            • 排名 - 5

            最新評論

            閱讀排行榜

            久久亚洲中文字幕精品一区| 日本三级久久网| 国内精品伊人久久久久| 国内精品久久久久久久亚洲| 中文成人久久久久影院免费观看| 亚洲AV无码一区东京热久久| 99久久精品无码一区二区毛片| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 伊人丁香狠狠色综合久久| 人妻少妇精品久久| 久久精品亚洲日本波多野结衣| 久久精品国产色蜜蜜麻豆| 久久综合亚洲欧美成人| 久久久亚洲精品蜜桃臀| 久久精品无码专区免费东京热| 久久一本综合| 久久精品国产免费一区| 久久妇女高潮几次MBA| 999久久久免费国产精品播放| 久久午夜无码鲁丝片秋霞| 丰满少妇人妻久久久久久4| 久久久国产打桩机| 久久精品无码一区二区日韩AV | 久久最近最新中文字幕大全| 国内精品久久久久影院亚洲| 91精品国产高清久久久久久91| 国产激情久久久久久熟女老人 | 久久久久无码中| 99久久久精品免费观看国产| 久久精品国产日本波多野结衣| 狠狠久久综合伊人不卡| 999久久久免费精品国产| 一本久久a久久精品vr综合| 人人狠狠综合久久亚洲| 国产福利电影一区二区三区久久老子无码午夜伦不 | 国产精品久久久香蕉| 精品久久久久久无码人妻蜜桃| 国产精品久久久久久久久鸭| 亚洲色婷婷综合久久| 伊人色综合久久天天人守人婷| 久久国产综合精品五月天|