I am getting this error only when compiling in debug mode. It saves the files alright but I get this after I close the window.
Code:int SaveClientInfo(HWND DialogHandle) { HANDLE File; Client Cliente; HWND NameEditBoxHwnd; HWND NameEditBox; DWORD dwWritten; HWND AddressBoxHandle; char * NameOfFile; char *FileToSave; char *NameOfClient; char *ClientAddress; int iCount; ZeroMemory(&Cliente,sizeof(Cliente)); NameEditBoxHwnd=GetDlgItem(DialogHandle, IDC_NOMBRE); iCount=GetWindowTextLength(NameEditBoxHwnd); //we incremente iCount to accomodate for the NULL character NameOfFile=new char [iCount]; GetWindowText(NameEditBoxHwnd,NameOfFile,iCount+1); FileToSave= new char [sizeof(NameOfFile)]; OpenFileName.hwndOwner = NULL; OpenFileName.lpstrFile = NameOfFile; OpenFileName.lpstrFileTitle =FileToSave; OpenFileName.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT ; GetSaveFileName (&OpenFileName); NameEditBox=GetDlgItem(DialogHandle, IDC_NOMBRE); iCount=GetWindowTextLength(NameEditBox); NameOfClient=new char [iCount]; GetWindowText(NameEditBox,NameOfClient,iCount+1); Cliente.SetName(NameOfClient); AddressBoxHandle=GetDlgItem(DialogHandle,IDC_ADDR); iCount=GetWindowTextLength(AddressBoxHandle); ClientAddress=new char [iCount]; GetWindowText(AddressBoxHandle,ClientAddress,iCount+1); Cliente.SetAddress(ClientAddress); File=CreateFile(OpenFileName.lpstrFileTitle, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); WriteFile(File, (char*)&Cliente, sizeof(Cliente), &dwWritten, NULL); /* I am having some serious problems with this stuff upon closing the window the program crashes.... how would I free the pointer memory? delete Pointer; Pointer=NULL; Should I do this here? Remember that this is called more than once thruout the program I think that it's because I am not freeing memory properly */ GlobalFree(NameOfFile); GlobalFree(FileToSave); GlobalFree(NameOfClient); GlobalFree(ClientAddress); CloseHandle(File); return Success; }



LinkBack URL
About LinkBacks


