Re: First-chance exception 0xC0000005 Access violation by saving procedure

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



CharsCount = GetWindowTextLength(hWndMainEditBox);
....
lpStringInEdit = (LPTSTR)HeapAlloc(GetProcessHeap(), 0,
CharsCount); //allocates memory for buffer

It looks like your allocated buffer is too small. The returned window text
length is the number of characters. In this special case: number of
WCHAR-characters! So you have to allocate (CharCount * sizeof(WCHAR)), or
better: (CharCount * sizeof(TCHAR)).

-peter


.