• <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>

            問題描述:大部分的vs.net 2005的用戶在新建“win32項目-windows應用程序”的時候,新建的工程都通不過去,出現如下提示:
            Solution to “MSVCR80D.dll not found” by hua.
            “沒有找到MSVCR80D.dll,因此這個應用程序未能啟動。重新安裝應用程序可能會修復此問題。”的完美解決方案^_^感覺偶做的還不錯

            問題所在:由于vs.net 2005 采用了一種新的DLL方案,搞成一個exe還要配有一個manifest文件(一般在嵌入文件里了,所以看不到,不過也可以不嵌入,這樣會生產一個<程序名>.exe.manifest的文件,沒它exe自己就轉不了了:)這是個新功能,微軟弄了個新工具(mt.exe),結果不好用,好像是fat32下時間戳有問題(在ntfs下這個問題就沒有了),搞得manifest有時嵌入不到exe中(默認配置是嵌入的,所以就報錯找不到dll了。

            解決方案(3個都可以,由以第3個最帥,我做的:):
            1.    微軟對于這個問題應該也有處理,不過感覺不是很人性化。在“屬性->配置屬性->清單工具->常規“下有一個”使用FAT32解決辦法,把它選成是,就可以了。(注意:一定要先配置這個選項,然后再編譯工程,要不然還是不好用:)
            2.    找到你的工程的文件夾,如(myproject),找到其下的myproject\myproject\Debug\ myproject.rec,把它刪掉(刪掉整個Debug目錄也可以),重新編譯,搞定!
            3.    本解決方案是俺獨創的,感覺爽多了,可以直接再應用向導中配置,嚴重符合高級人機界面要求:)好,
            1)    首先找到你的vs.net安裝目錄(如我的是E:\Program Files\Microsoft Visual Studio 8),定位到Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application文件夾,備份這個Application文件夾,不然一會你自己改咂了我可不管啊:)。
            2)    打開html\2052,看到兩個文件了吧,就那個AppSettings.htm了,這個管著你的那個配置向導的界面,用UE(不要告訴我你不知道ue啥東西,baidu it)打開,在266行“                </SPAN>”后回車,然后插入一下內容:
            <!-- this (hua)section is added by HUA. -->
                                <br><br><br><br><br>
                                
                            <span class="itemTextTop" id="FILE_SYSTEM_SPAN" title="">選擇你所使用的文件系統:
                                
                                   <P CLASS="Spacer"> </P>
                                
                                    <INPUT TYPE="radio" CLASS="Radio" checked onPropertyChange="" NAME="filesystem" ID="FAT32" ACCESSKEY="F" TITLE="FAT32">
                                    <DIV CLASS="itemTextRadioB" ID="FAT32_DIV" TITLE="FAT32">
                                    <LABEL FOR="FAT32" ID="FAT32_LABEL">FAT32(<U>F</U>)</LABEL>
                                    </DIV>

                                  <BR>

                                    <INPUT TYPE="radio" CLASS="Radio" onPropertyChange="" NAME="filesystem" ID="NTFS" ACCESSKEY="N" TITLE="NTFS">
                                    <DIV CLASS="itemTextRadioB" ID="NTFS_DIV" TITLE="NTFS">
                                    <LABEL FOR="NTFS" ID="NTFS_LABEL">NTFS(<U>N</U>)</LABEL>
                                    </DIV>
                            </span>
            <!-- end of (hua)section -->
            好,保存關閉,這個改完了,準備下一個。

            3)    打開scripts\2052,這里就一個文件,ue打開它,找到138行“        var bATL = wizard.FindSymbol("SUPPORT_ATL");”其后回車,插入如下內容:
            // this (hua)section is added by HUA.
                    var MFTool = config.Tools("VCManifestTool");
                    MFTool.UseFAT32Workaround = true;
            // end of (hua)section    
                    好,繼續找到210行(源文件的210,你加了上邊的語句就不是210了:)“        config = proj.Object.Configurations.Item("Release");”注意這次要在這行“前邊”加如下內容:
            // this (hua)section is added by HUA.
                    if(bFAT32)
                    {
                        var MFTool = config.Tools("VCManifestTool");
                        MFTool.UseFAT32Workaround = true;
                    }
            // end of (hua)section    
            好了,終于都改完了,打開你的vs.net 2005新建一個win32應用程序看看吧,效果還不錯吧:)為了這個問題,耽誤了我一天的考研復習時間,希望大家能用的上。
            另外附個國外的bbs:http://forums.microsoft.com/MSDN/default.aspx?SiteID=1
            Msdn的,肯定不錯了,上邊有vs.net的開發人員活動,都是很官方的東西,大家可以看看,不過英語要夠好哦:)

            (轉載)

            posted @ 2010-07-06 16:56 wrh 閱讀(251) | 評論 (1)編輯 收藏
            Windows XP IIS 完全安裝包

            Windows xp IIS 信息服務組件安裝包:

            該包中包含Windows xp 安裝盤I386文件夾內提取,只包含  IIS 信息服務組件.

            一: IIS 5.1版本適用于Windows XP_SP1、XP_SP2、XP_SP3

            二: ISS 5.1安裝步驟(各版本IIS都可以按照該方法安裝,以IIS5.1安裝至Windows xp_SP3為例)

            1.依次打開
            左下角的"開始"菜單----控制面板----選擇"添加/刪除程序",打開"添加/刪除程序"窗體
            ----點擊窗體左側"添加/刪除Windows組件"(A)

            2.解壓IIS 壓縮包,在打開的"Windows組件向導"窗體中,將"Internet 信息服務(IIS)"前面
            小方框鉤選上----點擊下一步-----在彈出的"插入磁盤"窗體中,點擊"確定"按扭------
            將解壓后的IIS 5.1路徑(如D:\飛翔下載\IIS\iis5.1xp)復制到"文件復制來源"輸入框中,
            如再遇到需要"插入光盤"之類的提示,繼續粘貼該IIS路徑即可,直到完成安裝,當出現安裝
            完成提示按扭時,點擊"完成"按扭關團向導,即可完成安裝.

            三: 問題及解決方案
            1.IIS安裝過程中,如果出現某些文件無法復制,則可能是該IIS不適合你的系統,請換一個 對應于系統的IIS,IIS版本說明如下.
            Windows XP_SP1 ,XP_SP2 ,XP_SP3 系統 適用 IIS5.1版本
            Windows 2000 系統 適用 IIS5.0 版本
            Windows server 2003系統 適用 IIS 6.0 版本
            Windows Server 2008 ,Vista 系統 適用 IIS 7.0 版本

            2.能完成IIS的安裝即無法正常使用等問題,部分原因如下
            可能與迅雷等網絡工具TCP 端口產生沖突,打開控制面板----雙擊"性能和維護"打開---
            "管理工具"----"Internet 信息服務"---"網站"---"選擇"默認網站"右擊---選擇"屬性"
            菜單---在默認網站屬性窗體分頁框內選擇"網站"標題---"TCP 端口" ----設為80即可完 成(IIS 默認80端口.如果使用其它端口,如8080,測試時需http://localhost:8080).
            3.IIS 80端口被占用的解決方法

            cmd 命令窗口----輸入netstat -abn ->c:/port80.txt然后到c盤port80.txt文件中找到 占用80端口的程序pid,記下pid.打開任務管理器,點擊"查看"/選擇列,勾選"PID(進程標識 符)",然后單擊"進程"標簽,找到80端口對應的pid,就可以看到是哪個程序占用的了,更改 這個程序的port,再重啟這個程序,使更改生效.再次啟動iis.

            posted @ 2010-05-15 09:39 wrh 閱讀(512) | 評論 (0)編輯 收藏

            1:新建安裝部署項目
            打開VS,點擊新建項目,選擇:其他項目類型->安裝與部署->安裝向導(安裝項目也一樣),然后點擊確定.(詳細見下圖)
            此主題相關圖片如下:


            2:安裝向導
            關閉后打開安裝向導,點擊下一步,或者直接點擊完成.


            3:開始制作
            安裝向導完成后即可進入項目文件夾:
            雙擊"應用程序文件夾"在右邊的空白處右擊,選擇添加->文件,將你的做的應用程序的可執行文件和相應的類庫和組件添加進來.

             

            然后右擊你的可執行文件,創建快捷方式,然后把快捷方式分別剪切或復制到左邊的"用戶的'程序'菜單"和"用戶桌面"中.
            這樣安裝程序安裝安裝完成后會在 "開始->所有程序"和"桌面"上生成程序的快捷方式.


            然后右擊左邊的"應用程序文件夾"打開屬性對話框:

            將屬性中的"defaultlocation"的路徑中的"[manufacturer]"去掉,
            不然的話做好的安裝程序默認安裝目錄會是"c:\programm file\你的用戶名\安裝解決方案名稱";

            然后打開解決方案管理器,右擊你的解決方案名稱,選擇屬性:


            在打開的屬性頁中,選擇"系統必備",

             

            在打開的系統必備頁中,選中如下中的選擇項,這個很重要!!!!!1!!!!!
            選上以后,在生成的安裝文件包中包含.netframework組件.(這個選項默認是沒有選中的)

             

             

            好了,這樣就完成99%了,然后點擊"生成->生成解決方案",哈,生成成功!
            4:制作完成
            現在打開解決方案文件夾下的debug文件夾,就可以看到生成的安裝文件了.

             

            【續】關于"卸載"功能的添加
            上面的文章只介紹了簡單的生成安裝的方法,
            但是在vs.net2005下并沒有直接生成卸載程序的功能,
            所以我們只好用msi來實現了,
            原理我就不講了,網上一搜一堆,我只講操作,
            【1】:在添加你的應用程序項目的時候,多添加一個msiexec.exe進去,
            這個文件在c:\windows\system32文件夾下,

             

            添加進去以后,為了讓他更像個卸載程序,把他的名字改成"Uninstall.exe",

             

            當然這個關系不大,改不改都行的.
            然后給他創建一個快捷方式,放到桌面或者"開始-程序"中,
            我選擇放在了開始菜單中,然后下面我們要的做的就是查找這個部署項目的ProductCode了,
            鼠標左鍵單擊項目名稱,記住是左鍵單擊,然后點擊屬性標簽,注意:不是右擊的屬性,
            這個區別很大,這時你就可以看到ProductCode了,

             

            然后打開你創建的那個快捷方式的屬性對話框,
            在Aguements屬性中輸入"/x {ProductCode}",

             

            好了,然后點擊"生成解決方案"即可生成帶有卸載功能的安裝程序了.


             

            posted @ 2010-05-11 21:04 wrh 閱讀(1083) | 評論 (0)編輯 收藏

            這種情況是由于對注冊表訪問權限不夠,拒絕訪問的意思,因此,注意看看權限是否不夠,如果改為
            KEY_ALL_ACCESS就沒問題了,這樣讀寫等權限都可以。

            posted @ 2010-05-09 16:33 wrh 閱讀(23532) | 評論 (1)編輯 收藏
             為什么RegQueryValueEx函數調用失敗,錯誤是無效句柄,可是RegOpenKeyEx調用成功了,返回正確的HKEY值,參數我都看好幾遍了,我實在不知道怎么回事,各位哥哥,姐姐指點一下吧 
            你是不是好幾次調用RegQueryValueEx,第一次正確,第二次就不正確了?
            看一下錯誤返回值,如果是234的話,應該是最后一個參數(表示長度的),第二次用的時候忘重新賦值了 
            posted @ 2010-05-09 10:22 wrh 閱讀(1226) | 評論 (0)編輯 收藏
            #include <windows.h>
            #include <stdio.h>
            #define BUFSIZE 80
            int main()
            {
            OSVERSIONINFOEX osvi;
            BOOL bOsVersionInfoEx;
            // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
            // If that fails, try using the OSVERSIONINFO structure.
            ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
            osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
            if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
            {
            osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
            if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
            return FALSE;
            }
            switch (osvi.dwPlatformId)
            {
            // Test for the Windows NT product family.
            case VER_PLATFORM_WIN32_NT:
            // Test for the specific product.
            if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
            printf ("Microsoft Windows Server 2003, ");
            if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
            printf ("Microsoft Windows XP ");
            if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
            printf ("Microsoft Windows 2000 ");
            if ( osvi.dwMajorVersion <= 4 )
            printf("Microsoft Windows NT ");
            // Test for specific product on Windows NT 4.0 SP6 and later.
            if( bOsVersionInfoEx )
            {
            // Test for the workstation type.
            if ( osvi.wProductType == VER_NT_WORKSTATION )
            {
            if( osvi.dwMajorVersion == 4 )
            printf ( "Workstation 4.0 " );
            else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
            printf ( "Home Edition " );
            else printf ( "Professional " );
            }
            // Test for the server type.
            else if ( osvi.wProductType == VER_NT_SERVER ||
            osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
            {
            if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
            {
            if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
            printf ( "Datacenter Edition " );
            else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
            printf ( "Enterprise Edition " );
            else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
            printf ( "Web Edition " );
            else printf ( "Standard Edition " );
            }
            else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
            {
            if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
            printf ( "Datacenter Server " );
            else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
            printf ( "Advanced Server " );
            else printf ( "Server " );
            }
            else  // Windows NT 4.0
            {
            if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
            printf ("Server 4.0, Enterprise Edition " );
            else printf ( "Server 4.0 " );
            }
            }
            }
            // Test for specific product on Windows NT 4.0 SP5 and earlier
            else
            {
            HKEY hKey;
            char szProductType[BUFSIZE];
            DWORD dwBufLen=BUFSIZE;
            LONG lRet;
            lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
            "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
            0, KEY_QUERY_VALUE, &hKey );
            if( lRet != ERROR_SUCCESS )
            return FALSE;
            lRet = RegQueryValueEx( hKey, "ProductType", NULL, NULL,
            (LPBYTE) szProductType, &dwBufLen);
            if( (lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE) )
            return FALSE;
            RegCloseKey( hKey );
            if ( lstrcmpi( "WINNT", szProductType) == 0 )
            printf( "Workstation " );
            if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
            printf( "Server " );
            if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
            printf( "Advanced Server " );
            printf( "%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion );
            }
            // Display service pack (if any) and build number.
            if( osvi.dwMajorVersion == 4 &&
            lstrcmpi( osvi.szCSDVersion, "Service Pack 6" ) == 0 )
            {
            HKEY hKey;
            LONG lRet;
            // Test for SP6 versus SP6a.
            lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
            "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
            0, KEY_QUERY_VALUE, &hKey );
            if( lRet == ERROR_SUCCESS )
            printf( "Service Pack 6a (Build %d)\n",
            osvi.dwBuildNumber & 0xFFFF );
            else // Windows NT 4.0 prior to SP6a
            {
            printf( "%s (Build %d)\n",
            osvi.szCSDVersion,
            osvi.dwBuildNumber & 0xFFFF);
            }
            RegCloseKey( hKey );
            }
            else // not Windows NT 4.0
            {
            printf( "%s (Build %d)\n",
            osvi.szCSDVersion,
            osvi.dwBuildNumber & 0xFFFF);
            }
            break;
            // Test for the Windows Me/98/95.
            case VER_PLATFORM_WIN32_WINDOWS:
            if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
            {
            printf ("Microsoft Windows 95 ");
            if (osvi.szCSDVersion[1]=='C' || osvi.szCSDVersion[1]=='B')
            printf("OSR2 " );
            }
            if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
            {
            printf ("Microsoft Windows 98 ");
            if ( osvi.szCSDVersion[1] == 'A' )
            printf("SE " );
            }
            if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
            {
            printf ("Microsoft Windows Millennium Edition\n");
            }
            break;
            case VER_PLATFORM_WIN32s:
            printf ("Microsoft Win32s\n");
            break;
            }
            return TRUE;
            }
            
            posted @ 2010-05-09 08:11 wrh 閱讀(766) | 評論 (0)編輯 收藏
            在開發過程中經常需要獲得程序當前的運行目錄,這時就可以使用GetCurrentDirectory()和GetModuleFileName()函數,GetCurrentDirectory只是返回當前進程的當前目錄,而并不是進程的鏡像文件(.exe)所在的目錄,GetCurrentDirectory()適用于XP等系統,,在WinCE上不能使用,GetModuleFileName()適用于WinCE2.0以后.

            函數說明:

            DWORD WINAPI GetModuleFileName(
            HMODULE hModule,
            LPTSTR lpFileName,
            DWORD nSize
            );
            函數功能
              此函數得到當前應用程序的運行目錄,還包括應用程序的文件名。
            參數說明
              hModule:要獲取文件名的模塊名柄,可以是運用LoadLiberary得到的句柄,null表示當前模塊
              lpFileName:輸出參數,存放取得的文件名
              nSize:lpFileName參數的長度

            DWORD GetCurrentDirectory(
               DWORD nBufferLength, // size of directory buffer
               LPTSTR lpBuffer // directory buffer
               );
            函數功能
             找到當前進程的當前目錄
            參數說明
              nBufferLength:lpBuffer緩沖區的長度
              lpBuffer:指定一個預定義字串,用于裝載當前目錄
            返回值
             調用成功 返回裝載到lpBuffer的字節數。

            使用方法:
            //下面的一段代碼主要是獲得當前程序的運行目錄(.exe)所在的目錄
            {
                CString path;
                GetModuleFileName(NULL,path.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
                path.ReleaseBuffer();
                int pos = path.ReverseFind('\\');
                path = path.Left(pos);
            }

            GetModuleFileName函數
             

            WINAPI DWORD GetModuleFileName(
            HMODULE hModule,
            LPWSTR lpFilename,
            DWORD nSize
            );

                GetBuffer和ReleaseBuffer是一套需要配合使用的函數, 與GetBufferSetLength相比, 優點是如果分配的空間大于實際保存的字符串(0結尾),ReleaseBuffer會把多余申請的空間釋放, 歸還給系統; 但使用時需要注意以下問題: 如果要保存的字符串為abc(0結尾),則GetBuffer參數應至少為3; 如果要保存的內容不是以0結尾, 比如是讀取文件數據, 則GetBuffer參數如果大于文件長度時,ReleaseBuffer參數一定要為文件長度(如果GetBuffer參數為文件長度的話不存在問題,ReleaseBuffer參數可以為默認-1)! GetBufferSetLength相對比較容易理解, 它申請一個指定長度的空間, 即使里面最終保存的字符串長度小于申請的空間長度, 也不會將多余空間釋放.

            調用示例:
            TCHAR *path = new TCHAR[MAX_PATH];
            ZeroMemory(path, MAX_PATH);
            // path == "d:\Project\Test\MFC\MFC\debug"
            GetCurrentDirectory(MAX_PATH, path);
            // path ==  "d:\Project\Test\MFC\debug\MFC.exe"
            GetModuleFileName(NULL,path,MAX_PATH);

            補充說明:
            如果想得到一個已經加載的DLL文件的路徑,可以運用以下方法:
            char  strPath[MAX_PATH];  
            GetModuleFileNameA(GetModuleHandle("你的DLL名字"),strPath,MAX_PATH);
            int j=strlen(strPath);
            for(j=strlen(strPath);strPath[j]!='\\';j--);
            strPath[j]='\0'; 
            其中strPath即為你的DLL文件所在的目錄

            posted @ 2010-04-24 08:20 wrh 閱讀(19261) | 評論 (0)編輯 收藏
                 摘要: 最近根據項目需要,需要我去用 vc++6.0 作一個 ActiveX web 組件。自己從來沒有接觸過這方面的編程,這次是頭一遭!所以咱就做了,不過倒很出乎我的意料,比我想象的要快很多就完成了。現將 vc++6.0 操作 word 部分的關鍵代碼部分帖出來,共享給大家。 因為我在開發的時候遇到了很多問題,并且網上的資料很少,基本都是最基本的操作。所以帖出來,希望能讓大家在開發的過程少走些彎路! ...  閱讀全文
            posted @ 2010-04-18 10:18 wrh 閱讀(2498) | 評論 (0)編輯 收藏
            This article was previously published under Q178749

            On This Page

            Expand all | Collapse all

            SUMMARY
            This article illustrates, in detail, how to automate component integration with...

            This article illustrates, in detail, how to automate component integration with COM-compliant applications such as the Microsoft Office applications.

            MORE INFORMATION
            The following section illustrates how you can create an MFC project. The example...

            The following section illustrates how you can create an MFC project. The example automates Microsoft Excel. You can use the first 8 steps for any project, and modify steps 9 through 15 when you work with another application.

            Create an automation project

            1. With Microsoft Developer Studio, start a new "MFC AppWizard (exe)" project named "AutoProject."
            2. In step 1 of the MFC AppWizard, choose "Dialog Based" for the application type and then click Finish.

              The New Project Information dialog box appears and indicates that the Classes to be created include:
                    Application: CAutoProjectApp in AutoProject.h and AutoProject.cpp
                                  Dialog: CAutoProjectDlg in AutoProject.h and AutoProjectDlg.cpp
                                  
              Click OK to create the project.
            3. The Dialog box "IDD_AUTOPROJECT_DIALOG" opens in the Visual Studio design/edit area. Modify it according to the instructions in the next two steps.
            4. Remove the Label control (IDC_STATIC) and the Cancel button (IDCANCEL).
            5. Change the name of the OK button to "IDRUN" and the caption to "Run." Close the AutoProject.rc dialog box design form.
            6. Click ClassWizard on the View menu (or press CTRL+W).
            7. Select the Message Maps tab. Select IDRUN in the Object Ids list box and select "BN_CLICKED" in the Messages list box. Click Add Function and accept the function name "OnRun". Click OK to close the ClassWizard.

              NOTE: This step adds a declaration for the function member "OnRun();" to the header file named AutoProjectDLG.h. This step also adds an empty skeleton message handler function named CAutoProjectDlg::OnRun() to the file named AutoProjectDLG.cpp.
            8. Click ClassWizard on the View menu (or press CTRL+W).
            9. Select the Automation tab. Click Add Class and choose "From a type library." Navigate to select the object library for the application you wish to automate (for this example, if you are automating Excel 97, choose the Microsoft Excel 8.0 Object Library; the default location is C:\Program Files\Microsoft Office\Office\Excel8.olb).

              If you are automating Microsoft Excel 2000, choose Microsoft Excel 9.0 Object Library for which the default location is the C:\Program Files\Microsoft Office\Office\Excel9.olb.

              If you are automating Microsoft Excel 2002 and Microsoft Office Excel 2003, the object library is embedded in the file Excel.exe. The default location for Excel.exe in Office 2002 is C:\program Files\Microsoft Office\Office10\Excel.exe. The default location for Excel.exe in Office 2003 is C:\program Files\Microsoft Office\Office11\Excel.exe. Once you have selected the appropriate object library, click Open. Select all classes in the Confirm Classes list, and then click OK.

              NOTE: The list box in the Confirm Classes dialog box contains all of the IDispatch interfaces (which are virtually identical to classes) in the Microsoft Excel type library. In the lower half of the dialog box you will see that an Implementation file named Excel8.cpp contains generated class wrappers derived from ColeDispatchDriver(), and the appropriate declaration header file is named Excel8.h. (For Excel 2002 and Excel 2003, the files are named Excel.cpp and Excel.h.)
            10. Click OK to close the MFC ClassWizard dialog box.
            11. Add the following code to the CAutoProjectApp::InitInstance() function, which loads and enables the COM services library:
                    BOOL CAutoProjectApp::InitInstance()
                                  {
                                  if(!AfxOleInit())  // Your addition starts here
                                  {
                                  AfxMessageBox("Could not initialize COM dll");
                                  return FALSE;
                                  }                 // End of your addition
                                  AfxEnableControlContainer();
                                  .
                                  .
                                  .
                                  }
                                  
            12. Add the following line to the #include statements at the top of the AutoProject.cpp program file:
                    #include <afxdisp.h>
                                  
            13. Add the include statement for excel8.h after the include statement for stdafx.h at the top of the AutoProjectDlg.cpp program file:
                    #include "stdafx.h"
                                  #include "excel8.h" // excel.h in the case of Excel 2002 and Excel 2003.
                                  
            14. Add automation code to the CAutoProjectDlg::OnRun() so that it appears as shown below:
                    void CAutoProjectDlg::OnRun()
                                  {
                                  _Application app;  // app is the Excel _Application object
                                  // Start Excel and get Application object...
                                  if(!app.CreateDispatch("Excel.Application"))
                                  {
                                  AfxMessageBox("Couldn't start Excel.");
                                  }
                                  else
                                  {
                                  //Make Excel Visible and display a message
                                  app.SetVisible(TRUE);
                                  AfxMessageBox ("Excel is Running!");
                                  }
                                  }
                                  
            15. Build and run the project. RESULTS: When you click the Run button in the dialog box, Microsoft Excel will be launched. Activate the Auto_Excel dialog box and dismiss the message box. Microsoft Excel will quit when the CAutoProjectDlg::OnRun() function ends because the application variable will have gone out of scope.

            Additional Notes

            Once you have added the classes from a type library to your project (as you did in step 9 above), you will notice that many classes have been added to the project. In ClassView, you can double-click a class to see the member functions of that class and then double-click the member function to view the definition of that function in the Excel8.cpp implementation file.

            You need to go to the definition of a member function if you wish to verify a return type or if you need to change a function's implementation. Any time you change a function definition, remember to change the declaration in the Excel8.h file. When doing so, be sure that you change the correct function declaration; sometimes, the same name is given to member functions of multiple classes--GetApplication() is one such example.

            Although the steps above illustrate how to automate Microsoft Excel, you can apply the same ideas to automating other applications. The list below contains the file names for the type libraries of the Microsoft Office applications:
               Application                           Type Library
                            --------------------------------------------------
                            Microsoft Access 97                   Msacc8.olb
                            Microsoft Jet Database 3.5            DAO350.dll
                            Microsoft Binder 97                   Msbdr8.olb
                            Microsoft Excel 97                    Excel8.olb
                            Microsoft Graph 97                    Graph8.olb
                            Microsoft Office 97                   Mso97.dll
                            Microsoft Outlook 97                  Msoutl97.olb
                            Microsoft PowerPoint 97               Msppt8.olb
                            Microsoft Word 97                     Msword8.olb
                            Microsoft Access 2000                 Msacc9.olb
                            Microsoft Jet Database 3.51           DAO360.dll
                            Microsoft Binder 2000                 Msbdr9.olb
                            Microsoft Excel 2000                  Excel9.olb
                            Microsoft Graph 2000                  Graph9.olb
                            Microsoft Office 2000                 Mso9.dll
                            Microsoft Outlook 2000                Msoutl9.olb
                            Microsoft PowerPoint 2000             Msppt9.olb
                            Microsoft Word 2000                   Msword9.olb
                            Microsoft Access 2002                 Msacc.olb
                            Microsoft Excel 2002                  Excel.exe
                            Microsoft Graph 2002                  Graph.exe
                            Microsoft Office 2002                 MSO.dll
                            Microsoft Outlook 2002                MSOutl.olb
                            Microsoft PowerPoint 2002             MSPpt.olb
                            Microsoft Word 2002                   MSWord.olb
                            Microsoft Office Access 2003          Msacc.olb
                            Microsoft Office Excel 2003           Excel.exe
                            Microsoft Graph 2003                  Graph.exe
                            Microsoft Office 2003                 MSO.dll
                            Microsoft Office Outlook 2003         MSOutl.olb
                            Microsoft Office PowerPoint 2003      MSPpt.olb
                            Microsoft Office Word 2003            MSWord.olb
                            
            NOTE: The default location for these type libraries is C:\Program Files\Microsoft Office\Office (for Office 2002 the path is C:\...\Office10 and for Office 2003 the path is C:\...\Office11), except for Dao350.dll or Dao360.dll, and Microsoft Office 10(MSO.dll). The default location for Dao350.dll/Dao360.dll is C:\Program Files\Common Files\Microsoft Shared\Dao. The default location for MSO.dll is C:\Program Files\Common Files\Microsoft Shared\Office10 for Office 2002 and C:\Program Files\Common Files\Microsoft Shared\Office11 for Office 2003.

            REFERENCES
            This article presents a specific approach to building a dialog-box project. If y...

            This article presents a specific approach to building a dialog-box project. If you would like to see more general documentation about the process of building a VC++ project in the Microsoft Developer Studio environment, there is an excellent tutorial you can access by using Visual Studio InfoView. To access the tutorial, click Search on the Help menu. Click the index tab and type the following:
            working with projects
            Click List Topics. Select the topic "Home Page: Working With Projects" and click Display. For more information about the automation of Office applications, click the following article number to view the article in the Microsoft Knowledge Base:
            222101  (http://support.microsoft.com/kb/222101/ ) How to find and use Office object model documentation

            APPLIES TO
            • Microsoft Foundation Class Library 4.2, when used with:
              • Microsoft Visual C++ 5.0 Standard Edition
              • Microsoft Visual C++ 6.0 Service Pack 5
            • Microsoft Office XP Developer Edition
            • Microsoft Office 2000 Developer Edition
            posted @ 2010-04-17 07:55 wrh 閱讀(1244) | 評論 (0)編輯 收藏
            _variant_t提示無法識別。
            解決方法:#include "comdef.h"
            該頭文件中定義了它。
            posted @ 2010-04-15 21:04 wrh 閱讀(581) | 評論 (0)編輯 收藏
            僅列出標題
            共25頁: First 8 9 10 11 12 13 14 15 16 Last 

            導航

            <2010年2月>
            31123456
            78910111213
            14151617181920
            21222324252627
            28123456
            78910111213

            統計

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲综合伊人久久大杳蕉| 国产视频久久| 久久久久久久久久久久中文字幕| 久久精品国产第一区二区三区| 久久精品国产秦先生| 亚洲精品无码久久久| 亚洲中文字幕久久精品无码APP | 色欲av伊人久久大香线蕉影院| 久久午夜无码鲁丝片| 久久久久免费视频| 久久久久久久久久久久中文字幕 | 久久精品国产久精国产一老狼| 激情伊人五月天久久综合| 欧美午夜精品久久久久久浪潮| 人妻无码久久一区二区三区免费| 久久99精品久久久久久秒播| 伊人久久大香线蕉综合Av| 久久精品国产一区二区| 99久久国产综合精品麻豆| 久久久久久久久久久精品尤物 | 久久中文字幕人妻熟av女| 色综合久久久久网| 国产亚洲精品美女久久久| 精品无码久久久久国产动漫3d| 久久91精品国产91久久麻豆| 亚洲国产精品无码久久久蜜芽| 日韩亚洲国产综合久久久| 久久97久久97精品免视看| 久久综合九色综合97_久久久| 久久久无码人妻精品无码| 亚洲中文字幕无码久久综合网| 国内精品久久国产| 国产精品成人久久久| 97久久国产露脸精品国产| 久久夜色精品国产| 亚洲国产综合久久天堂 | 99久久亚洲综合精品成人| 久久久久久狠狠丁香| 91久久九九无码成人网站| 久久久久国产视频电影| 久久伊人色|