Вниз
Скачать: CL | DM;

sharing violation   Найти похожие ветки 

← →
TUser ©   (2004-11-04 14:34) [0]

Почему, если файл открыт, как rewrite(filevar) и программа туда чего-то пишет, то его можно при этом открыть в другой программе для чтения. А если пишем через TFileStream - то при попытке открыть его (в FAR"е, например) - получаем ошибку? Типа - файл занят.


← →
panov ©   (2004-11-04 14:40) [1]

TUser ©   (04.11.04 14:34)

Смотря в каком режиме открываешь файл. см. глоб. переменную FileMode


← →
TUser ©   (2004-11-04 15:02) [2]

FileMode (судя по справке) влияеть не Reset. Я открывал Rewrite"ом.
Когда через стрим - то стоит fmOpenWrite, никакого fmShareDeny... нет, т.е. вроде бы файл д.б. доступен в других программах (по крайней мере для чтения) - ан нет.


← →
Rem ©   (2004-11-04 15:08) [3]

File open mode constants

File open mode constants are used to control the access mode to a file or stream.

Unit
SysUtils

Category
file management routines

const

 fmOpenRead       = $0000;
 fmOpenWrite      = $0001;
 fmOpenReadWrite  = $0002;

 fmShareCompat    = $0000;
 fmShareExclusive = $0010;
 fmShareDenyWrite = $0020;
 fmShareDenyRead  = $0030;
 fmShareDenyNone  = $0040;


Description

The file open mode constants are used when a file or stream is opened to control how it can be shared.

The TFileStream constructor has a Mode parameter that you can set to one of these constants:

Constant        Definition

fmCreate         If the file exists, open for write access,
                otherwise, create a new file.
                Unlike the other constants, which are declared
                in the SysUtils unit, this constant is
                declared in classes.pas.
fmOpenRead       Open for read access only.
fmOpenWrite      Open for write access only.
fmOpenReadWrite  Open for read and write access.
fmShareCompat    Compatible with the way FCBs are opened.
fmShareExclusive Read and write access is denied.
fmShareDenyWrite Write access is denied.
fmShareDenyRead  Read access is denied.
fmShareDenyNone  Allows full access for others.


← →
VMcL ©   (2004-11-04 15:24) [4]

>>TUser ©  (04.11.04 14:34)

TFileStream.Create(..., fmCreate) открывает  в монопольном режиме. См. исходники VCL.


← →
VMcL ©   (2004-11-04 15:29) [5]

>>TUser ©  (04.11.04 15:02) [2]

>Когда через стрим - то стоит fmOpenWrite, никакого fmShareDeny... нет, т.е. вроде бы файл д.б. доступен в других программах (по крайней мере для чтения) - ан нет.

Никому он ничего не должен :-)
Тогда срабатывает fmShareCompat = $0000. Ставь явно fmShareDenyNone или fmShareDenyWrite (см. [3]).



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.039 c
1-1099939023
Alan
2004-11-08 21:37
2004.11.21
Программа для чтения!


3-1098563512
Wint_
2004-10-24 00:31
2004.11.21
You have an error in your SQL syntax


9-1085817686
ПсихЪ
2004-05-29 12:01
2004.11.21
Анимированные текстуры


1-1100012690
DimonNew
2004-11-09 18:04
2004.11.21
StringGrid & Rect


3-1098266693
Aleksandr
2004-10-20 14:04
2004.11.21
Присвоение TDataBase.DataBaseName приводит к AV...




   Наверх