Re: CreateFile, ReadFile, WriteFile woes - VisualC++

From: Robert W Hand (rwhand_at_NOSPAMoperamail.com)
Date: 03/03/05


Date: Thu, 03 Mar 2005 06:40:14 -0500

On Thu, 3 Mar 2005 21:52:51 +1100, "Benjamin de Waal"
<yttrium@optusnet.com.au> wrote:

> hCardRead = CreateFile("\\\\.\\a:", GENERIC_READ, 0, NULL,
>OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
<snip>
>CreateFile, ReadFile and WriteFile are supposed to work. So I tried a
>little experiment and found that if I replace "\\\\.\\a:" with
>"c:\\somefile.txt" it works perfectly. This makes me think what I'm doing
>really SHOULD work, just doesn't.

Sorry, but something specifically Windows is off-topic here.

<OT>I'm not sure what you are trying to do with "\\\\.\\a:", but it
does look wrong if you are trying to open a file. If you are trying
to open a volume rather than a file, there are some potential serious
problems with CreateFile. Check out

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/naming_a_file.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp

Have you tried something like: "c:\\DataFile.ext"? You might also
want to check GetLastError.</OT>

-- 
Best wishes,
Bob


Relevant Pages

  • Re: File IO
    ... CFile is just a front end for CreateFile, ReadFile, ... CreateFile, ReadFile, and WriteFile use under the covers, but I guess I ...
    (microsoft.public.vc.mfc)
  • Re: _stprintf
    ... Here's the documentation for CreateFile: ... I don't blame Microsoft for not documenting Windows ME but I wonder why they ... "Since you can't use any multibyte encoding in CreateFile," ... to use MAX_PATH Kanji characters to name a file. ...
    (microsoft.public.vc.mfc)
  • Re: How to make the Windows to run a console program during OS startup?
    ... Replace all the IO function that use the Win32 API with the DDK IO ... that implement the CreateFile, then there is no need to modify my existing ... > CreateFile, ReadFile, WriteFile in that program? ...
    (microsoft.public.vc.mfc)
  • Re: How to make the Windows to run a console program during OS startup?
    ... Replace all the IO function that use the Win32 API with the DDK IO ... that implement the CreateFile, then there is no need to modify my existing ... > CreateFile, ReadFile, WriteFile in that program? ...
    (microsoft.public.dotnet.languages.vc)
  • Re: How to make the Windows to run a console program during OS startup?
    ... Replace all the IO function that use the Win32 API with the DDK IO ... that implement the CreateFile, then there is no need to modify my existing ... > CreateFile, ReadFile, WriteFile in that program? ...
    (microsoft.public.vc.language)