CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    429

    Question Using FindFirstFileEx to find a file of type .rpt [VC++6]

    There is a folder (\RptTmpl\) that should always be a folder of where my application is being run (so if the program is in c:\temp\ then there should be a c:\temp\rpttmpl\ folder), and in this folder there are a lot of .rpt files (report templates).
    I need to ensure there is at least ONE .rpt file in that folder, so I thought the best idea would be to use "FindFirstFileEx" to find the 1st .rpt file in that folder and if true then all is good and my program can continue (else return/exit).
    Problem is I can't seem to get my FindFirstFileEx to work correctly....

    Code:
    WIN32_FIND_DATA FindFileData;
    HANDLE hFind;
    hFind = FindFirstFileEx("\\DATA\\RPTTMPL\\*.rpt", &FindFileData);	// this is line 158
    if (hFind == INVALID_HANDLE_VALUE)
    {
    	return RET_NORPTTEMPLATES;
    }
    FindClose(hFind);
    Oddly this is causing two errors as shown below:
    Error #1: App.cpp(158) : error C2065: 'FindFirstFileEx' : undeclared identifier
    Error #2: App.cpp(158) : error C2440: '=' : cannot convert from 'int' to 'void *'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

    Any clue what I am doing wrong?
    Any help/hints would be greatly appreciated, thanks.

  2. #2
    Join Date
    Feb 2005
    Location
    Pasadena, MD, USA
    Posts
    105

    Re: Using FindFirstFileEx to find a file of type .rpt [VC++6]

    Hi,

    FindFirstFileEx takes 6 parameters. Are you confusing it with FindFirstFile?

    Jeff

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Using FindFirstFileEx to find a file of type .rpt [VC++6]

    MSDN
    FindFirstFileEx
    [...]
    To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0400 or later. For more information, see Using the SDK Headers.
    Anyhow, to simply assure there is at least one .rpt file in a folder FindFirstFile is much more than enough.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Jun 2005
    Posts
    1,255

    Smile Re: Using FindFirstFileEx to find a file of type .rpt [VC++6]

    FindFirstFileEx() is defined in winbase.h which is included in windows.h.

    It requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0, so the _WIN32_WINNT macro should be defined as 0x0400 or later.

    See http://msdn.microsoft.com/library/de...irstfileex.asp

    Edit: Ovidiu is quicker than me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured