Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2003.04.07;
Скачать: [xml.tar.bz2];

Вниз

Структурированые хранилища (doc-файлы)   Найти похожие ветки 

 
$hade   (2003-03-25 08:38) [0]

Народ! Кто разбирался с сабжем? Такая трабла: почти все ф-ии требуют параметр типа режим доступа (STGM_DIRECT or STGM_READ итак далее)
Трабла в том что почему-то необходимо всегда указывать флаг STGM_SHARE_EXCLUSIVE (блокирование доступа к объекту для других процессов) А МНЕ НУЖНО НАОБОРОТ!
код вылетает с exception"ом - Неверный флаг...

Год назад писал прогу - все работало...была D5 и WinNT 4.0 sp6

"Это жжжжж неспроста! по-моему так!"


 
$hade   (2003-03-25 10:24) [1]

Люди! Ну неужто никто не роазбирался с этим??


 
Севостьянов Игорь   (2003-03-25 12:13) [2]

StgOpenStorageEx
Opens an existing root storage object in the file system. You can use this function to open compound files and regular files. To create a new file, use the StgCreateStorageEx function.

Note All Microsoft Windows 2000 applications should use this new function, StgOpenStorageEx, instead of StgOpenStorage, to take advantage of the enhanced Windows 2000 Structured Storage features. The StgOpenStorage function still exists for compatibility with pre-Windows 2000 applications.

HRESULT StgOpenStorageEx(
const WCHAR *pwcsName, //Pointer to the path of the
// file containing storage object
DWORD grfMode, //Specifies the access mode for the object
STGFMT stgfmt, //Specifies the storage file format
DWORD grfAttrs, //Reserved; must be zero
STGOPTIONS *pStgOptions, //Address of STGOPTIONS pointer
void *reserved2, //Reserved; must be zero
REFIID riid, //Specifies the GUID of the interface pointer
void **ppObjectOpen //Address of an interface pointer
);
Parameters
pwcsName
[in] Pointer to the path of the file containing the storage object. This string size must not exceed MAX_PATH characters.
Windows 2000: Unlike the CreateFile function, the MAX_PATH limit cannot be exceeded by using the "\\?\" prefix.

grfMode
[in] Specifies the access mode to open the new storage object. For more information, see the STGM enumeration. If the caller specifies transacted mode together with STGM_CREATE or STGM_CONVERT, the overwrite or conversion takes place when the commit operation is called for the root storage. If IStorage::Commit is not called for the root storage object, previous contents of the file will be restored. STGM_CREATE and STGM_CONVERT cannot be combined with the STGM_NOSNAPSHOT flag, because a snapshot copy is required when a file is overwritten or converted in the transacted mode.
If the storage object is opened in direct mode (STGM_DIRECT), and with access of either STGM_WRITE or STGM_READWRITE, the sharing mode must be either STGM_SHARE_EXCLUSIVE or STGM_SHARE_DENY_WRITE, respectively.

The mode in which a file is opened can affect implementation performance. See Compound File Implementation Limits for more information

stgfmt
[in] Specifies the storage file format. For more information, see the STGFMT enumeration.
grfAttrs
[in] Depends on the value of the stgfmt parameter. STGFMT_DOCFILE All other values of stgfmt
Zero (0) or FILE_FLAG_NO_BUFFERING. See the CreateFile function for information on this value. If the sector size of the file (specified in ppStgOptions) is not an integer multiple of the underlying disk"s physical sector size, then this operation will fail. Must be 0


pStgOptions
[in, out] Pointer to a STGOPTIONS structure that contains information about the storage object being opened. The pStgOptions parameter is valid only if the stgfmt parameter is set to STGFMT_DOCFILE. The usVersion member must be set before calling StgOpenStorageEx. See STGOPTIONS structure.
reserved2
[in] Reserved for future use; must be zero.
riid
[in] Specifies the GUID of the interface pointer to return. Can also be the header-specified value for IID IStorage to obtain the IStorage interface or for IID IPropertySetStorage to obtain the IPropertySetStorage interface.
ppObjectOpen
[out] Address of an interface pointer variable that receives a pointer for an interface on the storage object being opened; contains NULL if operation failed.


 
Севостьянов Игорь   (2003-03-25 12:15) [3]

Return Values
S_OK
Indicates that the storage object was successfully opened.
STG_E_INVALIDPOINTER
Indicates a non-valid pointer in the ppObjectOpen parameter.
STG_E_INVALIDPARAMETER
Indicates a non-valid value for the grfAttrs, reserved1, reserved2, grfMode, or stgfmt parameters. Can occur if the FILE_FLAG_NO_BUFFERING flag is specified for grfAttrs, but the sector size of the file is not an integer multiple of the underlying disk"s sector size.
E_NOINTERFACE
Indicates that the specified interface is not supported.
STG_E_INVALIDFLAG
Indicates an non-valid flag combination in the grfMode pointer (includes both STGM_DELETEONRELEASE and STGM_CONVERT flags).
STG_E_INVALIDNAME
Indicates a non-valid name in the pwcsName parameter.
STG_E_INVALIDFUNCTION
Indicates that the grfMode is set to STGM_DELETEONRELEASE.
STG_E_LOCKVIOLATION
Access denied because another caller has the file open and locked.
STG_E_SHAREVIOLATION
Access denied because another caller has the file open and locked.
STG_E_UNIMPLEMENTEDFUNCTION
Indicates that the StgOpenStorageEx function is not implemented by the operating system. In this case, use the StgOpenStorage function instead.
STG_E_INCOMPLETE
Indicates that the file could not be opened because it is on a high-latency device. This can only occur if the riid parameter is IID_IPropertySetStorage, and the stgfmt parameter is STGFMT_FILE.
STG_E_ACCESSDENIED
Indicates that the file could not be opened because the underlying storage device does not allow such access to the current user. When opening the storage object in transacted mode (STGM_TRANSACTED), this error may also indicate that a temporary file could not be created in the temporary directory as specified by the GetTempPath function. The GetTempPath function retrieves the path of the directory designated for temporary files.
This function can also return any file system errors or Win32 errors wrapped in an HRESULT. See Error Handling Strategies, HRESULTs, Win32 and Network Errors, and Handling Unknown Errors.



 
Севостьянов Игорь   (2003-03-25 12:16) [4]

Remarks
StgOpenStorageEx is a superset of the StgOpenStorage function, and should be used by new code. Future enhancements to Windows structured storage will be exposed through this function. See the following Requirements section for information on supported platforms.

The StgOpenStorageEx function opens the specified root storage object according to the access mode in the grfMode parameter, and, if successful, supplies an interface pointer for the opened storage object in the ppObjectOpen parameter. This function can be used to obtain a compound file implementation of the IStorage or IPropertySetStorage, or to obtain an NTFS file system implementation of IPropertySetStorage.

When you open a file, the system selects a structured storage implementation depending on which STGFMT flag you specify on the file type and on the type of drive where the file is stored.

You can use the StgOpenStorageEx function to get access to the root storage of a structured storage document or the property set storage of any file that supports property sets. For information about which interface identifiers (IIDs) are supported for the different STGFMT values, see STGFMT.

When a file is opened with this function to access the NTFS property set implementation, special sharing rules apply. See IPropertySetStorage-NTFS Implementation.

If a compound file is opened in transcacted mode (by specifying STGM_TRANSACTED) and read-only mode (by specifying STGM_READ), it is possible to make changes to the returned storage object. For example, it is possible to call IStorage::CreateStream. However, it is not possible to commit those changes by calling IStorage::Commit. Therefore, such changes will be lost.

It is not valid to use the STGM_CREATE, STGM_DELETEONRELEASE, or STGM_CONVERT flags in the grfMode parameter for this function.

To support the simple mode for saving a storage object with no substorages, the StgOpenStorageEx function accepts the following flag combinations as valid modes in the grfMode parameter:

STGM_SIMPLE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE
and

STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE
To support the single-writer, multireader, direct mode, the following flag combination is the valid grfMode parameter for the writer:

STGM_DIRECT_SWMR | STGM_READWRITE | STGM_SHARE_DENY_WRITE
And the following combination is valid for readers:

STGM_DIRECT_SWMR | STGM_READ | STGM_SHARE_DENY_NONE
For more information on simple mode and single-writer/multiple-reader modes, see the STGM documentation.

Note Opening a transacted mode storage object in read and/or write mode without denying write permissions to others (the grfMode parameter specifies STGM_SHARE_DENY_WRITE) can be a time-consuming operation since the StgOpenStorageEx call must make a snapshot copy of the entire storage object.

Requirements
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Windows CE: Unsupported.
Header: Declared in objbase.h.

See Also
IStorage, StgCreateDocfile, StgCreateStorageEx, StgOpenStorage, STGFMT, STGM, STGOPTIONS


 
Севостьянов Игорь   (2003-03-25 12:22) [5]

Подводя итог всему вышеуказаному из MSDN - это просто из прочитанного, но неопробованому можно сказать попробуй вместо
STGM_SHARE_EXCLUSIVE использовать STGM_SHARE_DENY_WRITE для записи и STGM_SHARE_DENY_NONE
для чтения.
Т.е. можно сказать есть три комбинации:
Чтение/запись с эклюзивным доступом:
STGM_SIMPLE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE
Чтение с эклюзивным доступом:
STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE
Чтение/запись с открытым доступом:
STGM_DIRECT_SWMR | STGM_READWRITE | STGM_SHARE_DENY_WRITE
Чтение с открытым доступом:
STGM_DIRECT_SWMR | STGM_READ | STGM_SHARE_DENY_NONE


 
$hade   (2003-03-25 14:09) [6]

блин....в том то и дело что не работает так... без
exclusive выдает "неверный флаг"....(((
правда получилось создать/открыть файл нормально с
STGM_CREATE{для создания} or STGM_TRANSACTED or STGM_READWRITE or STGM_SHARE_DENY_NONE

но потом пытаюсь сделать поток
OleCheck(FRootStorage.CreateStream("VersionInfo", STGM_CREATE or STGM_WRITE or STGM_SHARE_DENY_NONE, 0, 0, stm));

и вот тут оно и вылетает...если поставить exclusive - все работает ((
тоже самое и с большинством других ф-ий...



 
Севостьянов Игорь   (2003-03-26 11:56) [7]

Извини я не работал с этим... Просто привел тебе мои предположения относительно прочитаного ... Прийдется тебе самому разбираться с этим вопросом...

Удачи...


 
$hade   (2003-03-26 14:02) [8]

лана...все равно сенкс за инфу...новое для себя нашел...

ок! мож кто еще подскажет??


 
Alex Konshin   (2003-03-27 07:24) [9]

Насколько я помню, у меня точно такие же проблемы в моем юните Storages. Я сколько там ни бился, но концов так и не нашел. Ну не работает оно так, как должно работать по MSDN. И помнится мне, что где-то я даже читал, что это еще не реализовано и не поддерживается.
Можешь для интереса посмотреть мое древнее творение на http://home.earthlink.net/~akonshin/index.htm


 
$hade   (2003-03-27 10:29) [10]

не реализовано что? не exclusive? Вот урёды!((((
Блин...ну я же вроде писал год назад...все работало...хотя...надо посмотреть...не помню уже...
Упс! Нет,оказывается и там Exclusive...ну чё делать то? :-(((((



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

Форум: "Основная";
Текущий архив: 2003.04.07;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.49 MB
Время: 0.007 c
1-19683
antoniz
2003-03-26 09:12
2003.04.07
Есть файл проекта, как из командной строки забилдить его


4-19920
xZero
2003-02-09 00:15
2003.04.07
PE


1-19545
les
2003-03-26 16:15
2003.04.07
Как посмотреть что внутри BPL


6-19734
ctapik-net
2003-02-16 12:30
2003.04.07
Управление WebBrowser ом из программы с помощью скрипта


14-19802
SaperXL
2003-03-20 00:44
2003.04.07
UUCP - программирование





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский