URGENT: Cannot create file with HANDLE CreateFile 
Author Message
 URGENT: Cannot create file with HANDLE CreateFile


Quote:
> Hi all,
>      Here is part of my code

> CHAR szFile[20];

> HANDLE hTestFile=CreateFile(szFile,FILE_ALL_ACCESS,
> NULL, NULL, CREATE_ALWAYS, NULL, NULL);

Try this:

CreateFile(
   szFile,
   FILE_ALL_ACCESS,
   0,
   NULL,
   CREATE_ALWAYS,
   FILE_ATTRIBUTE_NORMAL,
   NULL
   );

It's a good idea, to not use NULL for the various DWORD parameters - use the
appropriate default-action value.  Use NULL only for pointer-parameters for
which you're supplying no value.

The problem, I'm guessing, is with the value of the fwFlagsAndAttributes
parameter, to which you're passing NULL, and to which you should be passing
FILE_ATTRIBUTE_NORMAL.  Apparently Win2000 doesn't care while Win95 does.

HTH

-cd



Fri, 15 Apr 2005 22:48:56 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. URGENT: Cannot create file with HANDLE CreateFile

2. URGENT: Cannot create file with HANDLE CreateFile

3. URGENT: Cannot create file with HANDLE CreateFile

4. URGENT: Cannot create file with HANDLE CreateFile

5. URGENT: Cannot create file with HANDLE CreateFile

6. fstream cannot handle 46+ concurrently open files

7. Cannot access all comms ports using CreateFile()

8. Urgent : problem with file handling

9. any API to handle GIF file? ( urgent )

10. Help! Cannot create files in C

11. Help! Cannot create files in TC++

12. cannot create intermediate file MIDL error ?

 

 
Powered by phpBB® Forum Software