Cách khắc phục lỗi use _crt_secure_no_warnings

  1. Khắc phục lỗi lưu file dùng fopen[]
    Mình dùng hàm fopen[] trong FMC nhưng nó báo lỗi

    "error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\users\secret\desktop\chemgraphics\chemgraphics\ chemgraphicsview.cpp" mình đã xử lý bằng cách defined

Mã:

define _CRT_SECURE_NO_DEPRECATE

nhưng vẫn không được. Xin mọi người giúp đỡ. đây là đoạn code trong Viewclass của mình.

Mã:

void CChemGraphicsView::OnFileExport[] > { > // TODO: Add your command handler code here > CString szFilter; > szFilter.LoadString [IDS_WINDOWS_BITMAP_FILES]; > //Hien thi Save Dialog theo Path name > CFileDialog dlg [FALSE, DEFAULT_BITMAP_FILE_EXTENSION, DEFAULT_BITMAP_FILE_NAME, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, NULL]; > if [dlg.DoModal[] == IDOK] > { > CString szPathName = dlg.GetPathName[]; > //Tao file moi de ghi vao > FILE pFile = fopen [ szPathName, "wb"]; //error here >

if [pFile == NULL] > { > AfxMessageBox [IDS_FILE_CREATE_ERROR_MESSAGE]; > return; > } > BITMAPFILEHEADER bmfh; > int nBitsOffset = sizeof [BITMAPFILEHEADER] + BMIH.biSize; > LONG lImageSize = BMIH.biSizeImage; > LONG lFileSize = nBitsOffset + lImageSize; > bmfh.bfType = 'B' + ['M' bmfh.bfSize = lFileSize; > bmfh.bfReserved1 = bmfh.bfReserved2 = 0; > //write the bitmap file header > UINT nWrittenFileHeaderSize = fwrite [&bmfh, 1, sizeof [BITMAPFILEHEADER], pFile]; > //And then the bitmap info header > UINT nWrittenInfoHeaderSize = fwrite [&BMIH, 1, sizeof [BITMAPINFOHEADER], pFile]; > //Write the image data itseft -- hien thi du lieu ve > UINT nWrittenDIBDataSize = fwrite [m_pDrawingSurfaceBits, 1, lImageSize, pFile]; fclose[pFile]; > } > }

View more random threads:

Chuyển chữ thành số như nào? Xử lý tín hiệu số trong lập trình C Code di chuyển 1 đối tượng bằng bàn phím! Xem cái hàm này giùm mình tí! Bài tập về cấu trúc struct cần mọi ngưởi giúp đỡ Nhờ các bạn giúp mình ý nghĩa các hàm trong bài. lỗi code đồ họa may ban ho tro mih bai tim so chinh phuong

Chủ Đề