QT 或就用C++,如何取得Word的摘要信息?
网上查的用Win32读取的信息没有内容。QT使用QAXWidget不知道怎么调用。用WIN32方法在DWORD ret = GetFileVersionInfoSize(temp,&dw);就没有版本信息
LPCTSTR temp = VQTConvert::QString_To_LPCTSTR(m_strFullPathName);
DWORD ret = GetFileVersionInfoSize(temp,&dw);
int k;
if (0 == ret)
{
k= GetLastError();
}
//版本信息
void * buffer = new char[ret+1];
if(!GetFileVersionInfo(temp,0,ret+1,(LPVOID)buffer))
{
k = GetLastError();
}
//取得摘要
HRESULT hr;
struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
// Read the list of languages and code pages.
unsigned int cbTranslate =0;
VerQueryValue(buffer,
TEXT("\\VarFileInfo\\Translation"),
(LPVOID*)&lpTranslate,
&cbTranslate);
// Read the file description for each language and code page.
LPTSTR SubBlock;
void *lpBuffer;
unsigned int dwBytes;
for( int i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++ )
{
hr = StringCchPrintf(SubBlock, 50,
TEXT("\\StringFileInfo\\%04x%04x\\Comments"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
if (FAILED(hr))
{
// TODO: write error handler.
}
// Retrieve file description for language and code page "i".
VerQueryValue(buffer,
SubBlock,
&lpBuffer,
&dwBytes);
}
用QT的控件:
if (NULL == m_pWord)
{
m_pWord = new QAxWidget("Word.Application");
connect(m_pWord,SIGNAL(Quit()),this,SLOT(QuitWord()));
}
if (NULL == m_pWord)
{
return;
}
m_pWord->setProperty("Visible", true);
m_pDocuments = m_pWord->querySubObject("Documents");
if (NULL == m_pDocuments)
{
return;
}
m_pDocuments->dynamicCall("Open (\"c:/Bidding.document.temp\")");
m_pDocument = m_pWord->querySubObject("ActiveDocument");
if (NULL != m_pDocument)
{
connect(m_pDocument,SIGNAL(Close()),this,SLOT(CloseDocument()));
}
//////////////////////////////////////////////////////////////////////////
//m_pDocument->property();
IDispatch * p;
QVariant a ;
QAxObject *pro = m_pDocument->querySubObject("BuiltInDocumentProperties");
查看VBI控件,document是有BuiltInDocumentProperties属性和方法的。我用m_pDocument->querySubObject
m_pDocument->dynamicCall都取不到想要的值。用m-pDocument->("BuiltInDocumentProperties");返回一个IDISPATH *指针,之后就不知道要怎么才能取得自己想要的属性了,网上的资料很少。请牛人指点。
--------------------编程问答-------------------- 嘿嘿
回复内容太短了! --------------------编程问答-------------------- 恕我愚钝,你说的word的摘要信息具体指什么。
如果用MFC的话,可以去VC 知识库网站去看看 --------------------编程问答-------------------- for (int i = 1; i < 35; i++)
{
qDebug() << m_pDocument->dynamicCall("BuiltInDocumentProperties(const QVariant&)", QVariant(i)).toString();
}
1 Title
2 Subject
3 Author
4 Keywords
5 Comments
6 Template
7 Last author
8 Revision number
9 Application name
10 Last print date
11 Creation date
12 Last save time
13 Total editing time
14 Number of pages
15 Number of words
16 Number of characters
17 Security
18 Category
19 Format
20 Manager
21 Company
22 Number of bytes
23 Number of lines
24 Number of paragraphs
25 Number of slides
26 Number of notes
27 Number of hidden Slides
28 Number of 易做图 clips
29 Hyperlink base
30 Number of characters (with spaces)
31 Content type
32 Content status
33 Language
34 Document version --------------------编程问答-------------------- asdfadsfasdfasfafdadsf --------------------编程问答-------------------- 我有疑问,为什么要用QT调用WORD,用VB/C#/DELPHI不是更好吗 如果你要转换到LINUX下,恐怕还是不能调用啊? --------------------编程问答-------------------- 看看 word的基本协议 呵呵 应该可以解决。
补充:移动开发 , Qt