CFile in MSVC++ is MFC only?

Started by
5 comments, last by Anarchi 22 years, 2 months ago
After FILE *fp failed to deliver the goods, I was looking for an alternative. I came accross CFile (MSVC++6) which could do what I want without complication. I tried using it in my Win32 DirectX program, but it failed to compile as it required the afx.h header file. I included this file, but then it told me that Windows.h cannot be included in MFC applications! Is CFile specifically for MFC apps, or can I trick the compiler and use CFile without MFC? At the moment I''m using FILE *fp but it takes ages to truncate a huge 40MB file since I have to use a temp file

Downloads, D3DXSprite tutorial, New platform game: .-= The ZeroOne Realm =-.

Downloads, Free GoldLib game library, D3DXSprite tutorial, New platform game: .-= The ZeroOne Realm =-.

Advertisement
I think that is a part of MFC, and could only be used in MFC applcations. Maybe someone knows a way around this, but I don''t
CFile is just a wrapper around ANSI''s FILE. Or, more precice, they both resolve to Win32s API CreateFile, ReadFile, etc. So there''s no perfomance benefit using one or another.
And yes, CFile is a part of MFC - use it all or nothing.
Any wrapper will degrade performance, though it''s usually trivial and practically immesureable.

There''s no real problem with not being able to include Windows.h. If you need to do things like set WINVER or whatever, do that before you include afx.h.

I can''t imagine why using the C library functions wouldn''t have worked for you. If you can''t handle that, I can''t imagine how you''ll do much better with CFile, anyway. If your project is C++, maybe try ifstream and ofstream. But that will incurr overhead as well.
Didnt know about CreateFile and ReadFile, ill check them out, thanks

Downloads, Free GoldLib game library, D3DXSprite tutorial, New platform game: .-= The ZeroOne Realm =-.

Didnt know about CreateFile and ReadFile, ill check them out, thanks

Downloads, Free GoldLib game library, D3DXSprite tutorial, New platform game: .-= The ZeroOne Realm =-.

They''re even "harder" than the standard C stuff.

This topic is closed to new replies.

Advertisement