|
GetClassFile
Returns the CLSID associated with the given filename.
HRESULT GetClassFile(
LPCWSTR szFileName,
| //Pointer to filename for which you are requesting a CLSID
| CLSID * pclsid
| //Pointer to location for returning the CLSID
| );
|
|
Parameters
szFileName
Points to the filename for which you are requesting the associated CLSID.
pclsid
Points to the location where the the associated CLSID is returned.
Return Values
S_OK
Indicates the CLSID was successfully returned.
MK_E_CANTOPENFILE
Indicates unable to open the specified filename.
MK_E_INVALIDEXTENSION
Indicates the specified extension in the registry is invalid.
Note This function can also return any file system errors.
Comments
The CLSID returned by this function is used, for example, by File Monikers to
locate the object application that can open the file. For example, when a link
to a file-based document is activated, the file moniker uses the returned CLSID
to locate the application for the link source.
The following strategies are used to determine an appropriate CLSID:
- If the file contains a storage object, as determined by a call to the StgIsStorageFile function, the GetClassFile function returns the CLSID that was written with the IStorage::SetClass method.
- If the file is not a storage object, the GetClassFile function attempts to match various bits in the file against a pattern in the registry. A pattern in the
registry can contain a series of entries of the form:
regdb key = offset, cb, mask, value
The value of the offset item is an offset from the beginning or end of the file and the cb item is a length in bytes. These two values represent a particular byte range
in the file. (A negative value for the offset item is interpreted from the end of the file). The mask value is a bit mask that is used to perform a logical AND operation with the
byte range specifed by offset and cb. The result of the logical AND operation is compared with the value item. If the mask is omitted, it is assumed to be all ones.
Each pattern in the registry is compared to the file in the order of the
patterns in the database. The first pattern where each of the value items matches the result of the AND operation determines the CLSID of the
file. For example, the pattern contained in the following entries of the registry
requires that the first four bytes be AB CD 12 34 and that the last four bytes
be FE FE FE FE:
HKEY_CLASSES_ROOT
FileType
{12345678-0000-0001-C000-000000000095}
0 = 0, 4, FFFFFFFF, ABCD1234
1 = -4, 4, , FEFEFEFE
If a file contains such a pattern, the CLSID
{12345678-0000-0001-C000-000000000095} will be associated with this file.
- If the above strategies fail, the GetClassFile function searches for the File Extension key in the registry that corresponds to the .ext portion of the filename. If the database entry contains a valid CLSID, this function returns that
CLSID.
- Otherwise, MK_E_INVALIDEXTENSION is returned.
See Also
WriteClassStg
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|