/ Forside / Teknologi / Udvikling / C/C++ / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
C/C++
#NavnPoint
BertelBra.. 2425
pmbruun 695
Master_of.. 501
jdjespers.. 500
kyllekylle 500
Bech_bb 500
scootergr.. 300
gibson 300
molokyle 287
10  strarup 270
Låse en fil så den ikke kan kopieres?
Fra : Fungus


Dato : 19-09-01 12:00

Kan man fra C, på en windows platform, låse en fil således at den ikke kan
kopieres
mens den benyttes.

Renè



 
 
Søren B. Thygesen (19-09-2001)
Kommentar
Fra : Søren B. Thygesen


Dato : 19-09-01 14:39

"Fungus" <fungus@daimi.au.dk> wrote in message news:<3ba87a84$0$4795$ba624c82@nntp01.dk.telia.net>...
> Kan man fra C, på en windows platform, låse en fil således at den ikke kan
> kopieres
> mens den benyttes.
>
> Renè


Du kan bruge CreateFile() og angive 0 for "dwShareMode" jvf. MSDN:

HANDLE CreateFile(
LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDispostion ,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile);

[snip]

dwShareMode
[in] Specifies how the object can be shared. If dwShareMode is 0, the
object cannot be shared. Subsequent open operations on the object will
fail, until the handle is closed.
To share the object, use a combination of one or more of the following
values:

Value Description
FILE_SHARE_READ Subsequent open operations on the object will succeed
only if read access is requested.
FILE_SHARE_WRITE Subsequent open operations on the object will succeed
only if write access is requested.

[snip]

mvh,
S. Bro

Søg
Reklame
Statistik
Spørgsmål : 177501
Tips : 31968
Nyheder : 719565
Indlæg : 6408522
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste