在WINAPI中CreateFile函数的返回值是HANDLE类型,而OpenFile函数的返回值是HFILE类型?为什么?

解决方案 »

  1.   

    struct _iobuf {
            char *_ptr;
            int   _cnt;
            char *_base;
            int   _flag;
            int   _file;
            int   _charbuf;
            int   _bufsiz;
            char *_tmpfname;
            };
    typedef struct _iobuf FILE;
    typedef FILE* HFILE
    上面是HFILE的定义,我想你应该能看懂。typedef void* HANDLE
    只是一个void类型的指针。
      

  2.   

    OpenFile
    The OpenFile function creates, opens, reopens, or deletes a file. Note  This function is provided only for compatibility with 16-bit versions of Windows. New applications should use the CreateFile function. HFILE是16位操作系统下用的
    OpenFile返回的HFILE强制转换成HANDLE可以在ReadFile之类的函数里面用