Author Topic: [C/C++] FindFile function...issues  (Read 4012 times)

0 Members and 1 Guest are viewing this topic.

Offline ink

  • Newbie
  • *
  • Posts: 74
    • View Profile
[C/C++] FindFile function...issues
« on: February 12, 2006, 04:02:34 pm »
This is a sample code from MSDN for the findfile function that I edited a little (probably messed it up since I dont know squat about c) but yeah, im looking for guidence/direction

Code: [Select]

#define _WIN32_WINNT 0x0400

#include <windows.h>
#include <stdio.h>

int main()
{
char findFile [80];
WIN32_FIND_DATA FindFileData;
HANDLE hFind;

printf ("Enter file to find: ");
scanf ("%s",findFile);

hFind = FindFirstFile(findFile, &FindFileData);

if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Invalid File Handle. GetLastError reports %d\n",
GetLastError ());
return (0);
}
else
{
printf ("The first file found is %x\n",
FindFileData.cFileName);
FindClose(hFind);
return (1);
}
}



Problem I'm having at the moment is that it either returns saying its an invalid handle or that "The first file found is 12fe1c" everytime  ???

Offline zorm

  • Hero Member
  • *****
  • Posts: 591
    • View Profile
    • Zorm's Page
Re: [C/C++] FindFile function...issues
« Reply #1 on: February 12, 2006, 04:05:11 pm »
It totally helps if you give a problem or something that you are having.
"Frustra fit per plura quod potest fieri per pauciora"
- William of Ockham

Offline ink

  • Newbie
  • *
  • Posts: 74
    • View Profile
Re: [C/C++] FindFile function...issues
« Reply #2 on: February 12, 2006, 04:07:58 pm »
Scratch that problem, I had to change  the %x to %s
which brings up another question, what do %d, %s, and %x represent?


Um... scratch that question as well, and incase anybody else didn't know:
%d returns decimal value, %x returns hex value and %s returns string value, I think?
« Last Edit: February 12, 2006, 04:11:54 pm by ink »

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: [C/C++] FindFile function...issues
« Reply #3 on: February 12, 2006, 04:13:15 pm »