Try this (this one sets a comment which reads "Comment added here" to a file whose path is stored in fileName):
(add ole32.lib to project as statically linked library)
#include "ole2.h"
...
WCHAR wcFilename[1024];
IStorage *pStorage = NULL;
IPropertyStorage *pPropStg = NULL;
IPropertySetStorage *pPropSetStg = NULL;
PROPSPEC propspec[1];
PROPVARIANT propvarWrite[1];
HRESULT hr;
IID riid;
const FMTID fmtid = FMTID_SummaryInformation;
setlocale( LC_ALL, "" );
i = mbstowcs(wcFilename, fileName, strlen(fileName));
setlocale( LC_ALL, "C" );
wcFilename[i] = 0;
riid = IID_IPropertySetStorage;
hr
= StgOpenStorageEx(wcFilename, STGM_READ STGM_SHARE_DENY_WRITE,
STGFMT_FILE, 0, NULL,NULL, &riid, (void **)(&pStorage));
hr = pStorage->lpVtbl->QueryInterface(pStorage, &riid, (void **)&pPropSetStg);
hr
= pPropSetStg->lpVtbl->Create(pPropSetStg, &fmtid, NULL,
PROPSETFLAG_DEFAULT, STGM_CREATESTGM_READWRITESTGM_SHARE_EXCLUSIVE,
&pPropStg);
propspec[0].ulKind = PRSPEC_PROPID;
propspec[0].propid = PIDSI_COMMENTS;
propvarWrite[0].vt = VT_LPWSTR;
propvarWrite[0].pwszVal = L"Comment added here";
hr = pPropStg->lpVtbl->WriteMultiple(pPropStg,1,propspec, propvarWrite, NULL);
hr = pPropStg->lpVtbl->Commit(pPropStg, STGC_DEFAULT);
hr = pPropStg->lpVtbl->Release(pPropStg); pPropStg = NULL;
hr = pPropSetStg->lpVtbl->Release(pPropSetStg);
pPropSetStg = NULL;
The available properties to set are:
{"Title", PIDSI_TITLE},
{"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},
{"Last printed", PIDSI_LASTPRINTED},
{"Created", PIDSI_CREATE_DTM},
{"Last Saved", PIDSI_LASTSAVE_DTM},
{"Page Count", PIDSI_PAGECOUNT},
{"Word Count", PIDSI_WORDCOUNT},
{"Char Count", PIDSI_CHARCOUNT},
{"Thumbnail", PIDSI_THUMBNAIL},
{"AppName", PIDSI_APPNAME},
{"Doc Security", PIDSI_DOC_SECURITY}