Click to See Complete Forum and Search --> : fopen - very important problem
duvaft
December 19th, 2002, 09:16 AM
Hi,
if I create two applcation in C++. The first application open a file and send at the secondo application the pointer a file. The Second application fill the file and call the first application. The first application close the file.
Is possible to open a file from an application different of the application which fille the same file?
How?
Thanks !!!!
:confused: :confused: :confused:
dude_1967
December 19th, 2002, 09:57 AM
duvaft,
1) You should create and open the file with one application and perform the needed operations on the file for this one application. Then you must close the file in the first application.
2) Open the file in the second application (we will assume this file now exists and is closed). Be sure to use the append flag such that the contents of the file are not truncated or deleted. Move the file pointer to the end of the file and perform the operations on the file in the second application.
It is difficult on most modern operating systems to share file pointers between applications. If you really want to share an opened file among applications in the Win32 environment, you can take a look at "named kernel objects" and the established use of file-objects created using CreateFile(...).
Good luck.
Chris.
:)
kuphryn
December 19th, 2002, 10:36 AM
There are several solutions. One solution is file-mapping. This solution requeres that you know the second application is running. In other words, the two applications must be sychronized. This is not a problem since you are developing both applications.
Anothe solution is COM. This is more elegant and can be more difficult.
Kuphryn
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.