Здравствуйте!
собственно вопрос: почему Write file не может использовать объект напрямую, и ему обязательно нужен дескриптор?
4-я строчка с конца.
Заранее благодарен...
void Save(HWND hEdit, LPCTSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess = FALSE;
hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
// hFile != INVALID_HANDLE_VALUE
DWORD dwTextLength;
dwTextLength = GetWindowTextLength(hEdit);
// No need to bother if there's no text.
if(dwTextLength > 0)
{
TCHAR* pszText;
DWORD dwBufferSize = dwTextLength + 1;
pszText = (TCHAR*)new TCHAR[dwBufferSize];
if(pszText != NULL)
{
if(GetWindowText(hEdit, pszText, (dwBufferSize-1)))
{
DWORD dwWritten;
pszText[dwBufferSize-1]=NULL;
if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
bSuccess = TRUE;
}
delete pszText;
}
}
CloseHandle(hFile);
//return bSuccess;
}