FILE *file;
char m_buffer[24]="";
if((file = fopen("Server.txt","r")) != NULL)
          //总是打不开
{
fread(m_buffer,sizeof(char),23,file);
fclose(file);
::MessageBox(0,m_buffer,"!",MB_OK);
}
应该怎么做?

解决方案 »

  1.   

    检查其他原因,我觉得这个和COM没关系。
    GetLastErorr()可以返回上一个系统的错误。
    ============================================================================
    DocWizard C++ 程序文档生成工具 http://www.betajin.com/alphasun/index.htm
      

  2.   

    用CreateFile   SetFilePointer   ReadFile   WriteFile   函数啊,fopen函数在win32平台上最终还是要调用这些API函数的啊
      

  3.   


    to I_168_888(瓜棚下): 
    fopen函数在win32平台上最终还是要调用这些API函数的啊
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~谁说的?
    检查一下这个文本文件是否在exe文件执行的目录下
    如果是debug状态要copy到debug目录下
      

  4.   

    fopen 只是为了兼容而保留的接口,这些ANSI函数最终调用的是  win32 的函数。这是正确的============================================================================
    DocWizard C++ 程序文档生成工具 http://www.betajin.com/alphasun/index.htm
      

  5.   

    和COM没关系,查查打开文件是否在路径下。
      

  6.   

    试试把"if((file = fopen("Server.txt","r")) != NULL)"改成"if((file = fopen("Server.txt","r")) > 0)"
      

  7.   

    to alphapaopao(炮炮):
    你的意见我不敢苟同
    fopen是标准c的接口函数
    能够用于windows和unix平台
    而绝不是为了兼容性而保留的
    详见msdn:Compatibility
    The Microsoft run-time library supports American National Standards Institute (ANSI) C and UNIX® C. In this book, references to UNIX include XENIX®, other UNIX-like systems, and the POSIX subsystem in Windows NT and Windows 95. The description of each run-time library routine in this book includes a compatibility section for these targets: ANSI, Windows 95 (listed as Win 95), and Windows NT (Win NT). All run-time library routines included with this product are compatible with the Win32 API.