• <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 夢在天涯 閱讀(3605) 評論(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

            搜索

            •  

            積分與排名

            • 積分 - 1804159
            • 排名 - 5

            最新評論

            閱讀排行榜

            欧美日韩精品久久久久| 久久国产精品99久久久久久老狼 | 亚洲国产成人久久综合碰碰动漫3d | 欧美久久精品一级c片片| 久久99国产精品尤物| 久久精品国产亚洲av日韩| 亚洲人成伊人成综合网久久久| 色婷婷噜噜久久国产精品12p | 久久综合色区| 久久精品国产亚洲一区二区三区| 草草久久久无码国产专区| 精品无码久久久久久国产| 国产精品九九久久免费视频 | 色综合久久久久综合99| 亚洲国产精品综合久久一线| 国产香蕉久久精品综合网| 久久无码AV一区二区三区| 色综合久久久久综合体桃花网| 久久99精品久久只有精品| 97超级碰碰碰碰久久久久| 久久精品免费网站网| 狠狠综合久久综合88亚洲| 国产精品久久免费| 免费一级做a爰片久久毛片潮| 国内精品久久久久影院亚洲| 国内精品久久久久影院一蜜桃| 国产精品免费久久久久久久久| 久久综合伊人77777| 久久久久99精品成人片直播| 国产精品99久久久久久猫咪| 久久精品桃花综合| 精品久久一区二区| 2020久久精品亚洲热综合一本| 成人国内精品久久久久影院| 亚洲国产日韩欧美久久| 国产人久久人人人人爽| 久久频这里精品99香蕉久| 久久精品国产69国产精品亚洲| 精品久久久久久久久免费影院| 青青青青久久精品国产| 久久亚洲欧美国产精品|