Hi
We can add MFC support to console apps but hhy can't we add MFC support to Windows application?
I tried this:
It is compiled and executed but only CWinApp theApp; line is executed, before Winmain starts program exit. Why is it so?Code:#include <afx.h> #include <afxwin.h> #include <afxext.h> CWinApp theApp; int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { DWORD dwErrorCode; CString strErrorMessage; if(!(AfxWinInit(hInstance, hPrevInstance, (LPTSTR)lpCmdLine, nShowCmd))) { dwErrorCode = GetLastError(); strErrorMessage.Format(L"Error is = %d", dwErrorCode); AfxMessageBox(strErrorMessage); } HANDLE hFile = CreateFile(L"\\\\.\\C:\\a.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); CString cs; if(hFile == INVALID_HANDLE_VALUE) { dwErrorCode = GetLastError(); strErrorMessage.Format(L"Error is = %d", dwErrorCode); AfxMessageBox(strErrorMessage); }; CloseHandle(hFile); return 0; }
Thanks...




Reply With Quote