Article View: borland.public.cppbuilder.nativeapi
Article #191CreateFile to open a file already opened
From: Colin B Maharaj
Date: Wed, 02 Jul 2008 12:17
Date: Wed, 02 Jul 2008 12:17
27 lines
1748 bytes
1748 bytes
Hi all I used this function to open a file for read/write share deny
none like this....
FileHandle = FileOpen("MyFile.txt",fmOpenReadWrite|fmShareDenyNone);
then I opened the same file later on like this to read something...
no problem, (Note: I did not close the file handle above)
FileHandle2 = FileOpen("MyFile.txt", fmOpenRead |fmShareDenyNone);
...
FileClose(FileHandle2);
Finally I have this code I am using (not my code)
and is WinAPI and try to open the file similar to the
read operation above BUT IT FAILS!!
HANDLE hf =
CreateFile("MyFile.txt",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
// returns 0xffffffff
Any suggestions on how to get the 3rd line of code to behave like the
2nd line. Or, is an int FileHandle like what you see in 2nd line the
same as the HANDLE in the third.
Colin B Maharaj
Technical Details
Message-ID:
<486b71d7$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d59c8fd30fdb585e,start X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Wed, 02 Jul 2008 08:17:43 -0400 From: Colin B Maharaj <noreply@myhost.com> User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: CreateFile to open a file already opened Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 080701-0, 07/01/2008), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 190.58.98.8 Message-ID: <486b71d7$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1215001047 190.58.98.8 (2 Jul 2008 05:17:27 -0700) Lines: 29 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail