rt
如果及其上装了word调用api函数就可以了
String ls_null
SetNull (ls_null)
ShellExecuteA(Handle(Parent), ls_null, “c:\doc\hello.txt”, ls_null, ls_null, 1)
_Application m_App;//定义Word提供的应用程序对象;
Documents m_Docs;//定义Word提供的文档对象;
Selection m_Sel;//定义Word提供的选择对象;
m_Docs.ReleaseDispatch();
m_Sel.ReleaseDispatch();
m_App.m_bAutoRelease=true;
if(!m_App.CreateDispatch("Word.Application"))
{
AfxMessageBox("创建Word2000服务失败!");
exit(1);
}
//下面是定义VARIANT变量;
COleVariant varFilePath(strFilePath);
COleVariant varstrNull("");
COleVariant varZero((short)0);
COleVariant varTrue(short(1),VT_BOOL);
COleVariant varFalse(short(0),VT_BOOL);
m_Docs.AttachDispatch(m_App.GetDocuments());//将Documents类对象m_Docs和Idispatch接口关联起来;
m_Docs.Open(varFilePath,varFalse,varFalse,varFalse,
varstrNull,varstrNull,varFalse,varstrNull,
varstrNull,varTrue,varTrue,varTrue);
//打开Word文档;
m_Sel.AttachDispatch(m_App.GetSelection());//将Selection类对象m_Sel和Idispatch接口关联起来;
m_Sel.WholeStory ();//选择文档中的全部内容;