• <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項(xiàng)目-windows應(yīng)用程序”的時(shí)候,新建的工程都通不過去,出現(xiàn)如下提示:
            Solution to “MSVCR80D.dll not found” by hua.
            “沒有找到MSVCR80D.dll,因此這個(gè)應(yīng)用程序未能啟動(dòng)。重新安裝應(yīng)用程序可能會(huì)修復(fù)此問題。”的完美解決方案^_^感覺偶做的還不錯(cuò)

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

            解決方案(3個(gè)都可以,由以第3個(gè)最帥,我做的:):
            1.    微軟對(duì)于這個(gè)問題應(yīng)該也有處理,不過感覺不是很人性化。在“屬性->配置屬性->清單工具->常規(guī)“下有一個(gè)”使用FAT32解決辦法,把它選成是,就可以了。(注意:一定要先配置這個(gè)選項(xiàng),然后再編譯工程,要不然還是不好用:)
            2.    找到你的工程的文件夾,如(myproject),找到其下的myproject\myproject\Debug\ myproject.rec,把它刪掉(刪掉整個(gè)Debug目錄也可以),重新編譯,搞定!
            3.    本解決方案是俺獨(dú)創(chuàng)的,感覺爽多了,可以直接再應(yīng)用向?qū)е信渲茫瑖?yán)重符合高級(jí)人機(jī)界面要求:)好,
            1)    首先找到你的vs.net安裝目錄(如我的是E:\Program Files\Microsoft Visual Studio 8),定位到Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application文件夾,備份這個(gè)Application文件夾,不然一會(huì)你自己改咂了我可不管啊:)。
            2)    打開html\2052,看到兩個(gè)文件了吧,就那個(gè)AppSettings.htm了,這個(gè)管著你的那個(gè)配置向?qū)У慕缑妫肬E(不要告訴我你不知道ue啥東西,baidu it)打開,在266行“                </SPAN>”后回車,然后插入一下內(nèi)容:
            <!-- this (hua)section is added by HUA. -->
                                <br><br><br><br><br>
                                
                            <span class="itemTextTop" id="FILE_SYSTEM_SPAN" title="">選擇你所使用的文件系統(tǒng):
                                
                                   <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 -->
            好,保存關(guān)閉,這個(gè)改完了,準(zhǔn)備下一個(gè)。

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

            (轉(zhuǎn)載)

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

            Windows xp IIS 信息服務(wù)組件安裝包:

            該包中包含Windows xp 安裝盤I386文件夾內(nèi)提取,只包含  IIS 信息服務(wù)組件.

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

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

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

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

            三: 問題及解決方案
            1.IIS安裝過程中,如果出現(xiàn)某些文件無(wú)法復(fù)制,則可能是該IIS不適合你的系統(tǒng),請(qǐng)換一個(gè) 對(duì)應(yīng)于系統(tǒng)的IIS,IIS版本說明如下.
            Windows XP_SP1 ,XP_SP2 ,XP_SP3 系統(tǒng) 適用 IIS5.1版本
            Windows 2000 系統(tǒng) 適用 IIS5.0 版本
            Windows server 2003系統(tǒng) 適用 IIS 6.0 版本
            Windows Server 2008 ,Vista 系統(tǒng) 適用 IIS 7.0 版本

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

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

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

            1:新建安裝部署項(xiàng)目
            打開VS,點(diǎn)擊新建項(xiàng)目,選擇:其他項(xiàng)目類型->安裝與部署->安裝向?qū)?安裝項(xiàng)目也一樣),然后點(diǎn)擊確定.(詳細(xì)見下圖)
            此主題相關(guān)圖片如下:


            2:安裝向?qū)?br>關(guān)閉后打開安裝向?qū)?點(diǎn)擊下一步,或者直接點(diǎn)擊完成.


            3:開始制作
            安裝向?qū)瓿珊蠹纯蛇M(jìn)入項(xiàng)目文件夾:
            雙擊"應(yīng)用程序文件夾"在右邊的空白處右擊,選擇添加->文件,將你的做的應(yīng)用程序的可執(zhí)行文件和相應(yīng)的類庫(kù)和組件添加進(jìn)來(lái).

             

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


            然后右擊左邊的"應(yīng)用程序文件夾"打開屬性對(duì)話框:

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

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


            在打開的屬性頁(yè)中,選擇"系統(tǒng)必備",

             

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

             

             

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

             

            【續(xù)】關(guān)于"卸載"功能的添加
            上面的文章只介紹了簡(jiǎn)單的生成安裝的方法,
            但是在vs.net2005下并沒有直接生成卸載程序的功能,
            所以我們只好用msi來(lái)實(shí)現(xiàn)了,
            原理我就不講了,網(wǎng)上一搜一堆,我只講操作,
            【1】:在添加你的應(yīng)用程序項(xiàng)目的時(shí)候,多添加一個(gè)msiexec.exe進(jìn)去,
            這個(gè)文件在c:\windows\system32文件夾下,

             

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

             

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

             

            然后打開你創(chuàng)建的那個(gè)快捷方式的屬性對(duì)話框,
            在Aguements屬性中輸入"/x {ProductCode}",

             

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


             

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

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

            posted @ 2010-05-09 16:33 wrh 閱讀(23577) | 評(píng)論 (1)編輯 收藏
             為什么RegQueryValueEx函數(shù)調(diào)用失敗,錯(cuò)誤是無(wú)效句柄,可是RegOpenKeyEx調(diào)用成功了,返回正確的HKEY值,參數(shù)我都看好幾遍了,我實(shí)在不知道怎么回事,各位哥哥,姐姐指點(diǎn)一下吧 
            你是不是好幾次調(diào)用RegQueryValueEx,第一次正確,第二次就不正確了?
            看一下錯(cuò)誤返回值,如果是234的話,應(yīng)該是最后一個(gè)參數(shù)(表示長(zhǎng)度的),第二次用的時(shí)候忘重新賦值了 
            posted @ 2010-05-09 10:22 wrh 閱讀(1234) | 評(píng)論 (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 閱讀(767) | 評(píng)論 (0)編輯 收藏
            在開發(fā)過程中經(jīng)常需要獲得程序當(dāng)前的運(yùn)行目錄,這時(shí)就可以使用GetCurrentDirectory()和GetModuleFileName()函數(shù),GetCurrentDirectory只是返回當(dāng)前進(jìn)程的當(dāng)前目錄,而并不是進(jìn)程的鏡像文件(.exe)所在的目錄,GetCurrentDirectory()適用于XP等系統(tǒng),,在WinCE上不能使用,GetModuleFileName()適用于WinCE2.0以后.

            函數(shù)說明:

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

            DWORD GetCurrentDirectory(
               DWORD nBufferLength, // size of directory buffer
               LPTSTR lpBuffer // directory buffer
               );
            函數(shù)功能
             找到當(dāng)前進(jìn)程的當(dāng)前目錄
            參數(shù)說明
              nBufferLength:lpBuffer緩沖區(qū)的長(zhǎng)度
              lpBuffer:指定一個(gè)預(yù)定義字串,用于裝載當(dāng)前目錄
            返回值
             調(diào)用成功 返回裝載到lpBuffer的字節(jié)數(shù)。

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

            GetModuleFileName函數(shù)
             

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

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

            調(diào)用示例:
            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);

            補(bǔ)充說明:
            如果想得到一個(gè)已經(jīng)加載的DLL文件的路徑,可以運(yùn)用以下方法:
            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 閱讀(19274) | 評(píng)論 (0)編輯 收藏
                 摘要: 最近根據(jù)項(xiàng)目需要,需要我去用 vc++6.0 作一個(gè) ActiveX web 組件。自己從來(lái)沒有接觸過這方面的編程,這次是頭一遭!所以咱就做了,不過倒很出乎我的意料,比我想象的要快很多就完成了。現(xiàn)將 vc++6.0 操作 word 部分的關(guān)鍵代碼部分帖出來(lái),共享給大家。 因?yàn)槲以陂_發(fā)的時(shí)候遇到了很多問題,并且網(wǎng)上的資料很少,基本都是最基本的操作。所以帖出來(lái),希望能讓大家在開發(fā)的過程少走些彎路! ...  閱讀全文
            posted @ 2010-04-18 10:18 wrh 閱讀(2505) | 評(píng)論 (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 閱讀(1252) | 評(píng)論 (0)編輯 收藏
            _variant_t提示無(wú)法識(shí)別。
            解決方法:#include "comdef.h"
            該頭文件中定義了它。
            posted @ 2010-04-15 21:04 wrh 閱讀(586) | 評(píng)論 (0)編輯 收藏
            僅列出標(biāo)題
            共25頁(yè): First 8 9 10 11 12 13 14 15 16 Last 

            導(dǎo)航

            <2008年9月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            統(tǒng)計(jì)

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            亚洲乱码日产精品a级毛片久久 | 热RE99久久精品国产66热| 亚洲国产成人久久综合一 | AV无码久久久久不卡蜜桃| 久久精品欧美日韩精品| 2021久久精品国产99国产精品| 精品久久久久久| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 国产午夜精品理论片久久| 亚洲精品高清国产一久久| 久久无码一区二区三区少妇| 久久天天躁狠狠躁夜夜不卡| 久久婷婷综合中文字幕| 18禁黄久久久AAA片| 久久97精品久久久久久久不卡| 性做久久久久久久久| 精品国际久久久久999波多野 | 亚洲精品乱码久久久久久蜜桃不卡 | 97久久精品无码一区二区| 久久人人爽人人澡人人高潮AV| 久久综合狠狠综合久久综合88| 久久国产V一级毛多内射| 天天久久狠狠色综合| 色偷偷偷久久伊人大杳蕉| 久久久久久毛片免费看| 久久综合久久综合久久| 久久精品国产亚洲77777| 久久久国产视频| 久久国产精品一区| 91久久精品国产91性色也| 久久精品国产亚洲av麻豆小说| 久久精品国产AV一区二区三区 | 日本人妻丰满熟妇久久久久久| 久久久精品久久久久久| 狠狠狠色丁香婷婷综合久久五月| 亚洲人成伊人成综合网久久久| 亚洲国产视频久久| 欧美一级久久久久久久大片| 久久五月精品中文字幕| 久久久久综合国产欧美一区二区| 狠狠色伊人久久精品综合网|