So gehts:
std::string tmpstdStr = ttmpStr.c_str();
std::wstring tmpL(ttmpStr.Length() , L' ');
std::copy(tmpstdStr.begin(), tmpstdStr.end(), tmpL.begin());
------------------------------------------------------------------------------------
Hallo,
ich habe unter http://www.c-plusplus.de/forum/viewt...s-1491436.html
die readTitelOfFile Funktion, die den Titel einer Datei ausliest. D.h.
sie liest jetzt das aus was Datei Eigenschaften->Dateiinfo im Feld Titel
eingetragen wird.
Allerdiengs habe ich jetzt noch String-Konvertierungsprobleme, beim
aufruf der Datei.
std::wstring tmpL = L"c:\\test.pdf";
MyComboBox->Items->Add(readTitelOfFile(tmpL));
funktioniert.
Wie ich jetzt allerdiengs einen AnsiString in einen wstring umwandle:
std::wstring tmpL = ???hiereinAnsiString???
habe ich noch nicht herausgefunden.
Wie geht as? HILFE
------------------------------------------------------------------------------------------
AnsiString __fastcall TForm1::readTitelOfFile(std::wstring path)
{
//Typ des Titel - Propertysets
FMTID PropSetfmtid={0xf29f85e0,0x4ff9,0x1068,{0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9 }};
HRESULT hr = S_OK;
IPropertyStorage *pPropStg = NULL;
IPropertySetStorage *pPropSetStg = NULL;
PROPSPEC propspec;
PROPVARIANT propRead;
//Datei öffnen
hr = StgOpenStorageEx(path.c_str(),
STGM_READ | STGM_SHARE_DENY_WRITE, STGFMT_ANY, 0, NULL, NULL, IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg) );
if (hr != S_OK)
return "";
//Eigenschaften öffnen
hr = pPropSetStg->Open(PropSetfmtid, STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_READ, &pPropStg );
if (hr != S_OK)
return "";
//Setzen welche Information gelesen werden soll
propspec.ulKind = PRSPEC_PROPID;
propspec.propid = 0x00000002; //Titel
//Titel lesen
hr = pPropStg->ReadMultiple(1, &propspec, &propRead);
if (hr != S_OK)
return "";
//char-ANSI nach TCHAR-Unicode umsetzen
std::string temp = propRead.pszVal;
return AnsiString(temp.c_str());
}
std::string tmpstdStr = ttmpStr.c_str();
std::wstring tmpL(ttmpStr.Length() , L' ');
std::copy(tmpstdStr.begin(), tmpstdStr.end(), tmpL.begin());
------------------------------------------------------------------------------------
Hallo,
ich habe unter http://www.c-plusplus.de/forum/viewt...s-1491436.html
die readTitelOfFile Funktion, die den Titel einer Datei ausliest. D.h.
sie liest jetzt das aus was Datei Eigenschaften->Dateiinfo im Feld Titel
eingetragen wird.
Allerdiengs habe ich jetzt noch String-Konvertierungsprobleme, beim
aufruf der Datei.
std::wstring tmpL = L"c:\\test.pdf";
MyComboBox->Items->Add(readTitelOfFile(tmpL));
funktioniert.
Wie ich jetzt allerdiengs einen AnsiString in einen wstring umwandle:
std::wstring tmpL = ???hiereinAnsiString???
habe ich noch nicht herausgefunden.
Wie geht as? HILFE
------------------------------------------------------------------------------------------
AnsiString __fastcall TForm1::readTitelOfFile(std::wstring path)
{
//Typ des Titel - Propertysets
FMTID PropSetfmtid={0xf29f85e0,0x4ff9,0x1068,{0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9 }};
HRESULT hr = S_OK;
IPropertyStorage *pPropStg = NULL;
IPropertySetStorage *pPropSetStg = NULL;
PROPSPEC propspec;
PROPVARIANT propRead;
//Datei öffnen
hr = StgOpenStorageEx(path.c_str(),
STGM_READ | STGM_SHARE_DENY_WRITE, STGFMT_ANY, 0, NULL, NULL, IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg) );
if (hr != S_OK)
return "";
//Eigenschaften öffnen
hr = pPropSetStg->Open(PropSetfmtid, STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_READ, &pPropStg );
if (hr != S_OK)
return "";
//Setzen welche Information gelesen werden soll
propspec.ulKind = PRSPEC_PROPID;
propspec.propid = 0x00000002; //Titel
//Titel lesen
hr = pPropStg->ReadMultiple(1, &propspec, &propRead);
if (hr != S_OK)
return "";
//char-ANSI nach TCHAR-Unicode umsetzen
std::string temp = propRead.pszVal;
return AnsiString(temp.c_str());
}
Comment