问题描述:大部分的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 阅读(248) | 评论 (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 阅读(458) | 评论 (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 阅读(1074) | 评论 (0)编辑 收藏

这种情况是由于对注册表访问权限不够,拒绝访问的意思,因此,注意看看权限是否不够,如果改为
KEY_ALL_ACCESS就没问题了,这样读写等权限都可以。

posted @ 2010-05-09 16:33 wrh 阅读(23284) | 评论 (1)编辑 收藏
 为什么RegQueryValueEx函数调用失败,错误是无效句柄,可是RegOpenKeyEx调用成功了,返回正确的HKEY值,参数我都看好几遍了,我实在不知道怎么回事,各位哥哥,姐姐指点一下吧 
你是不是好几次调用RegQueryValueEx,第一次正确,第二次就不正确了?
看一下错误返回值,如果是234的话,应该是最后一个参数(表示长度的),第二次用的时候忘重新赋值了 
posted @ 2010-05-09 10:22 wrh 阅读(1203) | 评论 (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 阅读(762) | 评论 (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 阅读(19207) | 评论 (0)编辑 收藏
     摘要: 最近根据项目需要,需要我去用 vc++6.0 作一个 ActiveX web 组件。自己从来没有接触过这方面的编程,这次是头一遭!所以咱就做了,不过倒很出乎我的意料,比我想象的要快很多就完成了。现将 vc++6.0 操作 word 部分的关键代码部分帖出来,共享给大家。 因为我在开发的时候遇到了很多问题,并且网上的资料很少,基本都是最基本的操作。所以帖出来,希望能让大家在开发的过程少走些弯路! ...  阅读全文
posted @ 2010-04-18 10:18 wrh 阅读(2434) | 评论 (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 阅读(1183) | 评论 (0)编辑 收藏
_variant_t提示无法识别。
解决方法:#include "comdef.h"
该头文件中定义了它。
posted @ 2010-04-15 21:04 wrh 阅读(554) | 评论 (0)编辑 收藏
仅列出标题
共25页: First 8 9 10 11 12 13 14 15 16 Last 

导航

<2011年4月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

统计

常用链接

留言簿(19)

随笔档案

文章档案

收藏夹

搜索

最新评论

阅读排行榜

评论排行榜