Guest |
Отправлено: 05.12.2005, 22:24 |
|
Не зарегистрирован
|
Как запретить(чтобы ничем нельзя было открыть), а потом разрешить во время работы моей программы открытие скажем *.txt файла |
|
Guest |
Отправлено: 06.12.2005, 10:43 |
|
Не зарегистрирован
|
FileLock()
FileUnlock()
|
|
Guest |
Отправлено: 06.12.2005, 20:48 |
|
Не зарегистрирован
|
QUOTE |
FileLock()
FileUnlock()
|
А что это за функции, что-то я их описание в Help-е не нашел |
|
** Harold |
Отправлено: 07.12.2005, 00:48 |
|
Не зарегистрирован
|
Может быть имелась в виду Майкрософтовская
CODE |
LockFile
The LockFile function locks the specified file for exclusive access by the calling process using the specified file handle.
To specify additional options, use the LockFileEx function.
BOOL LockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow,
DWORD nNumberOfBytesToLockHigh
);
Parameters
hFile
[in] Handle to the file with a region to be locked. The file handle must have been created with the GENERIC_READ or GENERIC_WRITE access right. For more information, see File Security and Access Rights.
dwFileOffsetLow
[in] Low-order word of the starting byte offset in the file where the lock should begin.
dwFileOffsetHigh
[in] High-order word of the starting byte offset in the file where the lock should begin.
Windows Me/98/95: dwFileOffsetHigh must be 0, the sign extension of the value of dwFileOffsetLow. Any other value will be rejected.
nNumberOfBytesToLockLow
[in] Low-order word of the length of the byte range to be locked.
nNumberOfBytesToLockHigh
[in] High-order word of the length of the byte range to be locked.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Locking a region of a file gives the threads of the locking process exclusive access to the specified region using this file handle. If the file handle is inherited by a process created by the locking process, the child process is not granted access to the locked region.
Locking a region of a file does not prevent reading from a mapped file view.
You can lock bytes that are beyond the end of the current file. This is useful to coordinate adding records to the end of a file.
Locks may not overlap an existing locked region of the file.
If LockFile cannot lock a region of a file, it returns zero immediately. It does not block. To issue a file lock request that will block until the lock is acquired, use LockFileEx without LOCKFILE_FAIL_IMMEDIATELY.
If a process terminates with a portion of a file locked or closes a file that has outstanding locks, the locks are unlocked by the operating system. However, the time it takes for the operating system to unlock these locks depends upon available system resources. Therefore, it is recommended that your process explicitly unlock all files it has locked when it terminates. If this is not done, access to these files may be denied if the operating system has not yet unlocked them.
The UnlockFile function unlocks a file region locked by LockFile.
Example Code
For an example, see Appending One File to Another File.
Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
See Also
File Management Functions, CreateFile, LockFileEx, UnlockFile
|
Зы. Builder написан программистами для людей, а MS VC++ программистами для программистов... А Windows'ные фунции используют одни и те же... |
|
Gedeon |
Отправлено: 07.12.2005, 12:52 |
|
Ветеран
Группа: Модератор
Сообщений: 1742
|
QUOTE (** Harold @ 07/12/2005, 00:48) | Зы. Builder написан программистами для людей, а MS VC++ программистами для программистов... А Windows'ные фунции используют одни и те же... |
Не согласен, и там и там дело привычки, где-то встречалась тема, человек переходил с винапи на всл и имел немалые трудности.
|
|
** Harold |
Отправлено: 07.12.2005, 13:01 |
|
Не зарегистрирован
|
QUOTE | ....и имел немалые трудности |
Прямо даже не верится
Вот я и говорю, программистами для людей...
|
|
|