Click here to Skip to main content
15,900,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How do I use this api call for C++ Pin
Hamid_RT17-May-08 6:51
Hamid_RT17-May-08 6:51 
GeneralRe: How do I use this api call for C++ Pin
ThatsAlok6-Jul-09 21:01
ThatsAlok6-Jul-09 21:01 
GeneralRe: How do I use this api call for C++ Pin
Hamid_RT7-Jul-09 1:06
Hamid_RT7-Jul-09 1:06 
Questionnot allowing the edit option for an combobox Pin
sunny_vc17-May-08 0:13
sunny_vc17-May-08 0:13 
AnswerRe: not allowing the edit option for an combobox Pin
Gary R. Wheeler17-May-08 0:20
Gary R. Wheeler17-May-08 0:20 
AnswerRe: not allowing the edit option for an combobox Pin
Maxim Zarus17-May-08 0:21
Maxim Zarus17-May-08 0:21 
GeneralRe: not allowing the edit option for an combobox Pin
sunny_vc17-May-08 0:29
sunny_vc17-May-08 0:29 
QuestionCan't read the summary property of docx file Pin
Prazwol17-May-08 0:11
Prazwol17-May-08 0:11 
I am trying to read the summary property of docx file, i used the following code but get HRESULT S_FALSE while reading ReadMultiple.

Here is the code:

#include <stdio.h>
#include <windows.h>
#include <ole2.h>
#include <locale.h>

// Dumps simple PROPVARIANT values.
void DumpPropVariant(PROPVARIANT *pPropVar) {
// Don't iterate arrays, just inform as an array.
if(pPropVar->vt & VT_ARRAY)
{
printf("(Array)\n");
return;
}

// Don't handle byref for simplicity, just inform byref.
if(pPropVar->vt & VT_BYREF)
{
printf("(ByRef)\n");
return;
}

// Switch types.
switch(pPropVar->vt) {
case VT_EMPTY:
printf("(VT_EMPTY)\n");
break;
case VT_NULL:
printf("(VT_NULL)\n");
break;
case VT_BLOB:
printf("(VT_BLOB)\n");
break;
case VT_BOOL:
printf("%s (VT_BOOL)\n",
pPropVar->boolVal ? "TRUE/YES" : "FALSE/NO");
break;
case VT_I2: // 2-byte signed int.
printf("%d (VT_I2)\n", (int)pPropVar->iVal);
break;
case VT_I4: // 4-byte signed int.
printf("%d (VT_I4)\n", (int)pPropVar->lVal);
break;
case VT_R4: // 4-byte real.
printf("%.2lf (VT_R4)\n", (double)pPropVar->fltVal);
break;
case VT_R8: // 8-byte real.
printf("%.2lf (VT_R8)\n", (double)pPropVar->dblVal);
break;
case VT_BSTR: // OLE Automation string.
{
// Translate into ASCII.
char dbcs[1024];
char *pbstr = (char *)pPropVar->bstrVal;
int i = wcstombs(
dbcs, pPropVar->bstrVal, *((DWORD *)(pbstr-4)));
dbcs[i] = 0;
printf("%s (VT_BSTR)\n", dbcs);
}
break;
case VT_LPSTR: // Null-terminated string.
{
printf("%s (VT_LPSTR)\n", pPropVar->pszVal);
}
break;
case VT_FILETIME:
{
char *dayPre[] =
{"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};

FILETIME lft;
FileTimeToLocalFileTime(&pPropVar->filetime, &lft); SYSTEMTIME lst;
FileTimeToSystemTime(&lft, &lst);

printf("%02d:%02d.%02d %s, %s %02d/%02d/%d (VT_FILETIME)\n",
1+(lst.wHour-1)%12, lst.wMinute, lst.wSecond,
(lst.wHour>=12) ? "pm" : "am",
dayPre[lst.wDayOfWeek%7],
lst.wMonth, lst.wDay, lst.wYear);
}
break;
case VT_CF: // Clipboard format.
printf("(Clipboard format)\n");

break;
default: // Unhandled type, consult wtypes.h's VARENUM structure.
printf("(Unhandled type: 0x%08lx)\n", pPropVar->vt);
break;
}
}

// Dump's built-in properties of a property storage.
void DumpBuiltInProps(IPropertySetStorage *pPropSetStg) {
printf("\n==================================================\n");
printf("BuiltInProperties Properties...\n");
printf("==================================================\n");

IPropertyStorage *pPropStg = NULL;
HRESULT hr;
PROPVARIANT propRead;
HRESULT Enum(IEnumSTATPROPSETSTG** PropEnum);

// Open summary information, getting an IpropertyStorage.
hr = pPropSetStg->Open(FMTID_SummaryInformation,
STGM_READ | STGM_SHARE_EXCLUSIVE, &pPropStg);

if(FAILED(hr))
{
printf("No Summary-Information.\n");
return;
}

// Array of PIDSI's you are interested in.
struct pidsiStruct {
char *name;
long pidsi;
} pidsiArr[] = {
{"Title", PIDSI_TITLE}, // VT_LPSTR
{"Subject", PIDSI_SUBJECT}, // ...
{"Author", PIDSI_AUTHOR},
{"Keywords", PIDSI_KEYWORDS},
{"Comments", PIDSI_COMMENTS},
{"Template", PIDSI_TEMPLATE},
{"LastAuthor", PIDSI_LASTAUTHOR},
{"Revision Number", PIDSI_REVNUMBER},
{"Edit Time", PIDSI_EDITTIME}, // VT_FILENAME (UTC)
{"Last printed", PIDSI_LASTPRINTED}, // ...
{"Created", PIDSI_CREATE_DTM},
{"Last Saved", PIDSI_LASTSAVE_DTM},
{"Page Count", PIDSI_PAGECOUNT}, // VT_I4
{"Word Count", PIDSI_WORDCOUNT}, // ...
{"Char Count", PIDSI_CHARCOUNT},

{"Thumpnail", PIDSI_THUMBNAIL}, // VT_CF
{"AppName", PIDSI_APPNAME}, // VT_LPSTR
{"Doc Security", PIDSI_DOC_SECURITY}, // VT_I4
{0, 0}
};

// Count elements in pidsiArr.
int nPidsi = 0;
for(nPidsi=0; pidsiArr[nPidsi].name; nPidsi++);

// Initialize PROPSPEC for the properties you want.
PROPSPEC *pPropSpec = new PROPSPEC [nPidsi];
PROPVARIANT *pPropVar = new PROPVARIANT [nPidsi];

for(int i=0; i<npidsi; i++)="">
{
ZeroMemory(&pPropSpec[i], sizeof(PROPSPEC));
pPropSpec[i].ulKind = PRSPEC_PROPID;
pPropSpec[i].propid = pidsiArr[i].pidsi;
}

// Read properties.
hr = pPropStg->ReadMultiple(nPidsi, pPropSpec, pPropVar);

if(FAILED(hr)) // HERE I GOT hr = S_FALSE
{
printf("IPropertyStg::ReadMultiple() failed w/error %08lx\n", hr);
}
else
{
int i;
// Dump properties.
for(i=0; i<npidsi; i++)="">
{
printf("%16s: ", pidsiArr[i].name);
DumpPropVariant(pPropVar + i);
}
}

// De-allocate memory.
delete [] pPropVar;
delete [] pPropSpec;

// Release obtained interface.
pPropStg->Release();

}

// Dump's custom and built-in properties of a compound document.
void DumpProps(char *filename) {
// Translate filename to Unicode.
WCHAR wcFilename[1024];
setlocale( LC_ALL, "" );
int i = mbstowcs(wcFilename, filename, strlen(filename));
setlocale( LC_ALL, "C" );
wcFilename[i] = 0;

IPropertySetStorage *pPropSetStg = NULL;
HRESULT hr;

hr = ::StgOpenStorageEx(wcFilename, STGM_READ | STGM_SHARE_EXCLUSIVE, STGFMT_ANY,
0, NULL, NULL, IID_IPropertySetStorage, (void**)&pPropSetStg);

if(FAILED(hr))
{
printf("QI for IPropertySetStorage failed w/error %08lx", hr);
pStorage->Release();
return;
}

// Dump properties.
DumpBuiltInProps(pPropSetStg);

// Release obtained interfaces.
pPropSetStg->Release();
}

// Program entry-point.
void main(int argc, char **argv) {
char *s;
DumpProps("1.docx");
scanf("%s",&s);
}
AnswerRe: Can't read the summary property of docx file Pin
Iain Clarke, Warrior Programmer17-May-08 0:27
Iain Clarke, Warrior Programmer17-May-08 0:27 
QuestionHow can I get user accout details ? Pin
SherTeks17-May-08 0:03
SherTeks17-May-08 0:03 
AnswerRe: How can I get user accout details ? Pin
Hamid_RT17-May-08 0:51
Hamid_RT17-May-08 0:51 
QuestionHow can handle Enter key in TreeCtrl? Pin
Le@rner16-May-08 22:09
Le@rner16-May-08 22:09 
AnswerRe: How can handle Enter key in TreeCtrl? Pin
Naveen16-May-08 22:39
Naveen16-May-08 22:39 
GeneralRe: How can handle Enter key in TreeCtrl? Pin
Le@rner17-May-08 0:44
Le@rner17-May-08 0:44 
GeneralRe: How can handle Enter key in TreeCtrl? Pin
Hamid_RT17-May-08 0:47
Hamid_RT17-May-08 0:47 
GeneralRe: How can handle Enter key in TreeCtrl? Pin
Le@rner17-May-08 1:53
Le@rner17-May-08 1:53 
GeneralRe: How can handle Enter key in TreeCtrl? Pin
Hamid_RT17-May-08 4:13
Hamid_RT17-May-08 4:13 
GeneralRe: How can handle Enter key in TreeCtrl? Pin
Le@rner18-May-08 18:37
Le@rner18-May-08 18:37 
GeneralRe: How can handle Enter key in TreeCtrl? Pin
Hamid_RT18-May-08 19:11
Hamid_RT18-May-08 19:11 
Questionplz help me to write a program in c++ Pin
Qasimsha16-May-08 21:25
Qasimsha16-May-08 21:25 
AnswerRe: plz help me to write a program in c++ Pin
Michael Schubert16-May-08 22:11
Michael Schubert16-May-08 22:11 
AnswerRe: plz help me to write a program in c++ Pin
Michael Schubert16-May-08 22:32
Michael Schubert16-May-08 22:32 
GeneralRe: plz help me to write a program in c++ Pin
Iain Clarke, Warrior Programmer17-May-08 13:43
Iain Clarke, Warrior Programmer17-May-08 13:43 
JokeRe: plz help me to write a program in c++ Pin
Michael Schubert17-May-08 22:40
Michael Schubert17-May-08 22:40 
AnswerRe: plz help me to write a program in c++ Pin
Naveen16-May-08 22:41
Naveen16-May-08 22:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.