http://blogs.msdn.com/b/pranavwagh/archive/2007/03/03/word-2007-file-seems-to-be-deleted-when-you-open-and-save-it-using-dsoframer.aspx
http://blogs.msdn.com/b/pranavwagh/archive/2007/03/03/word-2007-file-seems-to-be-deleted-when-you-open-and-save-it-using-dsoframer.aspx
————————————————————————————————————————————————————————
This is one of the interesting cases I had lately. My customer was using DSOFramer sample to host Office Documents, but whenever he tried to open and save Word 2007 documents in this manner, guess what !! the file seems to be deleted !
As I am basically a VB guy I did not want to bother myself with VC++ code of DSOFramer, because I've had easier ways to troubleshoot. The first thing I tried was Process Monitor from sysinternals. I could see that we are moving the file to a temp directory and then while saving it we are saving the changes in it. hmm..strange!
Then I checked DSOFramer code and I realized that IPersist:Save() is returning S_OK, it doesn't look like there is some issue whatsoever. Then moved to Word 2007 code, to me it looks like a bug in the implementation of IPersist:Save().
So ..to tackle this I had to modify the code of DSOFramer a bit, being more precise I modified the code of "CDsoDocObject::SaveStorageToFile" [this is in source file dsofdocobj.cpp]. Here is the modified code:
if (SUCCEEDED(hr = m_pole->QueryInterface(IID_IPersistFile, (void**)&pipfile)))
{
//Get the current open file
LPWSTR pwszCurPath = new WCHAR(MAX_PATH+1);
pipfile->GetCurFile(&pwszCurPath);
//Perform save.
hr = pipfile->Save(pwszFile, FALSE);
pipfile->Release();
//Save results S_OK, but the document is saved to the original location (IPersistFile->GetCurFile) in Word 2007.
//We will just check if that's the case and move the file.
if (SUCCEEDED(hr) && !FFileExists(pwszFile))
{
//We should come here only in case of Word 2007.
CopyFileW(pwszCurPath, pwszFile, TRUE);
}
}
Ok..bye for now.. will be back in a day with some more, and yes I am starting to do technorati and del.icio.us tagging
Asim Shah 20 Mar 2007 3:09 AMI've tried this change in my version of the DSOFramer and I get a compile time error as there is no variable available called pwsxCurPath.
I downloaded my source from the KB311765 link (same as the one you provide links to).
Did you get your source from somewhere else?
Asim Shah (asimshah@hotmail.com)
Hey..i am sorry ..there was a typo in my code..i corrected it
Jag 29 Mar 2007 2:42 AMCan someone please send to me the working dsoframer fixed to: jag_vb at. hotmail
thnks
Hello ..sir, nobody will send it to you. You 'll need to work on it! its a sample, provided as-is, and i am sorry there was a typo in my code, i corrected it- 1 Jan 2008 2:46 PM
According to MSDN, IPersistFile::GetCurFile allocates the string buffer for you so I think there's a memory leak in your code.
Here's what I believe to be correct (not yet tested though):
//Get the current open file
LPWSTR pwszCurPath = NULL;
if (S_OK != pipfile->GetCurFile(&pwszCurPath))
{
pwszCurPath = NULL;
}
//Perform save.
hr = pipfile->Save(pwszFile, FALSE);
pipfile->Release();
//Save results S_OK, but the document is saved to the original location (IPersistFile->GetCurFile) in Word 2007.
//We will just check if that's the case and move the file.
if (SUCCEEDED(hr) && !FFileExists(pwszFile) && pwszCurPath != NULL)
{
//We should come here only in case of Word 2007.
CopyFileW(pwszCurPath, pwszFile, TRUE);
}
if (pwszCurPath != NULL)
{
CoTaskMemFree(pwszCurPath);
pwszCurPath = NULL;
}
http://blogs.msdn.com/b/pranavwagh/archive/2007/03/03/word-2007-file-seems-to-be-deleted-when-you-open-and-save-it-using-dsoframer.aspx的更多相关文章
- POI 读取word (word 2003 和 word 2007)(转,好用)
POI 读取word (word 2003 和 word 2007)(转,好用) 转做的操作: 将作者文中失效的链接的正确链接放在失效链接的下面. 最近在给客户做系统的时候,用户提出需求,要能够导入 ...
- http://www.cnblogs.com/Lawson/archive/2012/09/03/2669122.html
http://www.cnblogs.com/Lawson/archive/2012/09/03/2669122.html
- Word 2007 文档结构图混乱
Word 2007在编写大型文档时经常出现文档结构图混乱的情况,经过多番检索试验,得出结论: 绝对有效的临时性解决方案:在打开word的时候左下角会有提示word自动更新文档样式,按esc键取消,然后 ...
- [转]彻底征服Word 2007标题多级列表
[转]彻底征服Word 2007标题多级列表 用Word编写文档的人都知道,一篇长文档一般是需要分章节来划分段落的.在Word中也有对应的工具来完成这项任务,这就是多级列表.然而绝大多数使用Micro ...
- Windows XP和Word 2007不能正常使用VSTO插件
今天帮助同事解决了一个小问题,就是在WindowsXP上,为Word2007开发的插件不能正常显示. 通过搜索关键词 WindowsXp Word 2007 VSTO找到了两个解决方案. http:/ ...
- POI 读取word (word 2003 和 word 2007) (转)
最近在给客户做系统的时候,用户提出需求,要能够导入 word 文件,现在 microsoft word 有好几个版本 97.2003.2007的,这三个版本存储数据的格式上都有相当大的差别,而现在 9 ...
- http://www.cnblogs.com/Matrix54/archive/2012/05/03/2481260.html
http://www.cnblogs.com/Matrix54/archive/2012/05/03/2481260.html
- Embedding Documents in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office
Download the sample code This visual how-to article presents a solution that creates a Word 2007 doc ...
- Word 2007 封面、目录和正文页码单独设置
word 2007 生成目录比较简单,即使不会,也可以百度,很快就能弄好.现在有如下需求: 1.封面去掉页码 2.目录页码从1开始,页码在页脚底部中间位置,格式为[1] 3.正文也从1开始,页码在页脚 ...
随机推荐
- npm使用过程中的一些错误解决办法及npm常用命令
node,npm在前端开发流程中提供了非常完善的自动化工具链,但是同样由于其复杂性导致有很多奇奇怪怪的问题.本文将记录使用过程中出现的一些问题及其解决方法备案. 国内由于gfw问题,导致很多国外的网站 ...
- UVa401 回文词
Palindromes A regular palindrome is a string of numbers or letters that is the same forward as backw ...
- Yii2 CSRF
一.CSRF 即Cross-site request forgery跨站请求伪造,是指有人冒充你的身份进行一些恶意操作. 比如你登录了网站A,网站A在你的电脑设置了cookie用以标识身份和状态,然后 ...
- gcc与g++
gcc和g++都是GNU(组织)的一个编译器. 误区一:gcc只能编译c代码,g++只能编译c++代码两者都可以,但是请注意:1.后缀为.c的,gcc把它当作是C程序,而g++当作是c++程序:后缀为 ...
- scala学习笔记(1):基本语法与容器
1 var 可变,val 不可变 var (a,b) = (10,20) 分别对a,b赋值 a=10, b=20 var a,b = (10,20)则 是a=(10,20) b=(10,20) 2 L ...
- 深入学习Heritrix---解析CrawlController(转)
当我们以Web UI方式使用Heritrix时,点击任务开始(start)按钮时,Heritrix就开始了它的爬取工作.但它的内部 执行流程是怎样的呢?别急,下面将慢慢道来. (一)CrawlJobH ...
- 通过 XtraBackup 实现不停机不锁表搭建主从同步
简介 Xtrabackup是由 Percona 开发的一个开源软件,可实现对 InnoDB 的数据备份,支持在线热备份(备份时不影响数据读写).备份时,Xtrabackup 会将 Master 的 b ...
- 【转】itunes connect 如何修改主要语言
原文网址:http://blog.csdn.net/yuedong56/article/details/50662181 刚开始提交app,没有做国际化(本地化),提交的app只有简体中文一种语言,第 ...
- App中嵌入网页浏览器
TOWebViewController 插件 NSURL *url =[NSURL URLWithString:@"http://192.168.1.134:8180/Home/IndexP ...
- Web开发基础
一.后台 1.MyEclipse:Java Web的编辑器 2.Java Servlet:后台代码 3.Velocity:前后台接口 4.mySql:数据库 二.前台 1.js:前台代码 2.jQue ...