Using open and then LockFile for a file 
Author Message
 Using open and then LockFile for a file

Hi all,

I'm porting a Unix application to Windows. Im using M$ VC++ compiler.
My problem is that on Unix the file locking mechanism is done using
the fcntl() function that doesn't exist on Windows. I know that on
Windows I can do this using CreateFile() to get the HANDLE to a file
and then this handle can be used in LockFile() for locking the file.

But, I would like to open the file using open() function, which
returns an "int" and then for using the LockFile() I need a HANDLE to
the file, so my question is: is there a function that can transform
the "int" returned by open() into a HANDLE that then can be used in
LockFile() ?

Thanks in advance,
vc



Sun, 31 Jul 2005 17:36:03 GMT  
 Using open and then LockFile for a file

Quote:

> I'm porting a Unix application to Windows. Im using M$ VC++
> compiler.  My problem is that on Unix the file locking mechanism is
> done using the fcntl() function that doesn't exist on Windows. I
> know that on Windows I can do this using CreateFile() to get the
> HANDLE to a file and then this handle can be used in LockFile() for
> locking the file.

What about File#flock?

--
matt



Mon, 01 Aug 2005 00:48:09 GMT  
 Using open and then LockFile for a file

comp.lang.c++:

Quote:
> Hi all,

> I'm porting a Unix application to Windows. Im using M$ VC++ compiler.
> My problem is that on Unix the file locking mechanism is done using
> the fcntl() function that doesn't exist on Windows. I know that on
> Windows I can do this using CreateFile() to get the HANDLE to a file
> and then this handle can be used in LockFile() for locking the file.

> But, I would like to open the file using open() function, which
> returns an "int" and then for using the LockFile() I need a HANDLE to
> the file, so my question is: is there a function that can transform
> the "int" returned by open() into a HANDLE that then can be used in
> LockFile() ?

> Thanks in advance,
> vc

Please don't post non-standard stuff like this to comp.lang.c++ in the
future.  If it is not part of the C++ language, as defined by the ISO
standard, it is off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq



Mon, 01 Aug 2005 09:37:44 GMT  
 Using open and then LockFile for a file
Quote:
----- Original Message -----

Newsgroups:
comp.os.ms-windows.programmer.win32,comp.lang.ruby,comp.lang.c++,microsoft.p
ublic.dotnet.languages.vc

Sent: Wednesday, February 12, 2003 7:46 PM
Subject: Re: Using open and then LockFile for a file

> Please don't post non-standard stuff like this to comp.lang.c++ in the
> future.  If it is not part of the C++ language, as defined by the ISO
> standard, it is off-topic here.

If it's off-topic on comp.lang.c++, it's
WAY off-topic on comp.lang.ruby...   ;)

Cheers,
Hal



Mon, 01 Aug 2005 09:52:32 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. opening a lockfile

2. error 37 File not open using a variable file name

3. Opening Files using Char Expressions.

4. Open VFP 5.0 files using Clipper

5. Open an avi file using ftp

6. How to replace or create a file using the open/create/replace.vi

7. Open a SEQ file using LabVIEW

8. Opening file using PLAIN_TEXT_FILE or RAW_FILE and getting OS error status back

9. Using OS/2 REXX to modify file objects opening menu

10. opening local .wrl files using WorldView

11. Problem using OPEN command with an integer file name

12. Opening files using wildcards with Watcom F77/386?

 

 
Powered by phpBB® Forum Software