STDMETHODIMP FileStore:: WriteData (BSTR Dateiname, BSTR Daten)
{
CComBSTR filePath = store_path;
filePath.Append (Dateiname);
HANDGRIFF hFile =:: CreateFile (filePath, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dwBytesWritten = 0;
DWORD dwFileSize;
TCHAR* pszUnicodeBuff;
dwFileSize = wcslen (Daten);
pszUnicodeBuff = (TCHAR*) LocalAlloc (LPTR, (+1) dwFileSize * sizeof (TCHAR));
_tcsncpy (pszUnicodeBuff, Daten, dwFileSize);
:: WriteFile (hFile, pszUnicodeBuff (LPCVOID), (+1) dwFileSize * sizeof (TCHAR), &dwBytesWritten, NULL);
:: CloseHandle (hFile);
Rückhol-S_OK;
}
//-------------------------------------------------
STDMETHODIMP FileStore:: ReadData (BSTR Dateiname, BSTR* Daten)
{
DWORD dwBytesWritten = 0;
DWORD dwFileSize;
CHAR* pszFileBuff = 0;
TCHAR* pszUnicodeBuff;
CComBSTR filePath = store_path;
filePath.Append (Dateiname);
HANDGRIFF hFile = CreateFile (filePath, GENERIC_READ | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
dwFileSize = GetFileSize (hFile, NULL);
pszFileBuff = (char*) LocalAlloc (LPTR, dwFileSize);
ReadFile (hFile, pszFileBuff (LPVOID), dwFileSize, &dwBytesWritten, NULL);
pszUnicodeBuff = (TCHAR*) LocalAlloc (LPTR, sizeof (TCHAR) * (+ 1) dwFileSize);
mbstowcs (pszUnicodeBuff, (const Putzfrau *) pszFileBuff, (size_t) strlen (pszFileBuff));
CloseHandle (hFile);
RückholSysReAllocString (Daten, pszUnicodeBuff);
}
|