CreateFile() giving errors

This is a discussion on CreateFile() giving errors within the Windows Programming forums, part of the Platform Specific Boards category; I'm using VS 6, Windows 2003. Code: hLayerFile = CreateFile("ltmp.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); I get this error: ...

  1. #1
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640

    CreateFile() giving errors

    I'm using VS 6, Windows 2003.

    Code:
    hLayerFile = CreateFile("ltmp.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    I get this error:
    Code:
    error C2440: '=' : cannot convert from 'void *' to 'struct HWND__ *'
    When I hover the mouse over the CreateFile() function, it gives a weird declaration of it.

    Code:
    void *__cdecl CreateFile(unsigned short *, unsigned long, unsigned long, _SECURITY_ATTRIBUTES *, unsigned long, unsigned long, void *);
    Did I miss something? What happened to CreateFile?

    More on my project, as I have a feeling it has something to do with the error. I'm writing a dll plugin for a program. Here's the top part of driver.cpp:

    Code:
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    Any ideas on what I should do? I created a new Win32 Dynamic-Link Library project and started coding. I'm having no other (known)errors other than the few CreateFile() calls. Thanks for help.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Could it be that you have declared hLayerFile as:
    Code:
    HWND hLayerFile;
    rather than:
    Code:
    HANDLE hLayerFile;
    The CreateFile prototype looks correct for a unicode build, except for the cdecl calling convention. I assume this is just a "quirk" of the IDE?

  3. #3
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Yes, changed HWND to HANDLE and fixed it. I just jumped back into windows programming after a long break from it. Didn't catch that. Thanks.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 11:50 AM
  2. Header File Errors...
    By Junior89 in forum C++ Programming
    Replies: 5
    Last Post: 07-08-2007, 01:28 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21