1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/registry.cpp
3 // Purpose: implementation of registry classes and functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 // TODO: - parsing of registry key names
11 // - support of other (than REG_SZ/REG_DWORD) registry types
12 // - add high level functions (RegisterOleServer, ...)
13 ///////////////////////////////////////////////////////////////////////////////
16 #pragma implementation "registry.h"
19 // ============================================================================
21 // ============================================================================
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 // for compilers that support precompilation, includes "wx.h".
28 #include "wx/wxprec.h"
34 // other wxWindows headers
35 #include "wx/string.h"
39 #include "wx/config.h" // for wxExpandEnvVars
44 #define WIN32_LEAN_AND_MEAN
50 #include <stdlib.h> // for _MAX_PATH
57 #define HKEY_DEFINED // already defined in windows.h
58 #include "wx/msw/registry.h"
60 // some registry functions don't like signed chars
61 typedef unsigned char *RegString
;
63 // ----------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------
67 // the standard key names, short names and handles all bundled together for
73 const char *szShortName
;
77 { HKEY_CLASSES_ROOT
, "HKEY_CLASSES_ROOT", "HKCR" },
79 { HKEY_CURRENT_USER
, "HKEY_CURRENT_USER", "HKCU" },
80 { HKEY_LOCAL_MACHINE
, "HKEY_LOCAL_MACHINE", "HKLM" },
81 { HKEY_USERS
, "HKEY_USERS", "HKU" }, // short name?
82 { HKEY_PERFORMANCE_DATA
, "HKEY_PERFORMANCE_DATA", "HKPD" },
84 { HKEY_CURRENT_CONFIG
, "HKEY_CURRENT_CONFIG", "HKCC" },
86 { HKEY_DYN_DATA
, "HKEY_DYN_DATA", "HKDD" }, // short name?
88 #endif //WINVER >= 4.0
92 // the registry name separator (perhaps one day MS will change it to '/' ;-)
93 #define REG_SEPARATOR '\\'
95 // useful for Windows programmers: makes somewhat more clear all these zeroes
96 // being passed to Windows APIs
97 #define RESERVED (NULL)
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
102 // @ const_cast<> is not yet supported by all compilers
103 #define CONST_CAST ((wxRegKey *)this)->
106 #define m_dwLastError CONST_CAST m_dwLastError
109 // ----------------------------------------------------------------------------
110 // non member functions
111 // ----------------------------------------------------------------------------
113 // removes the trailing backslash from the string if it has one
114 static inline void RemoveTrailingSeparator(wxString
& str
);
116 // returns TRUE if given registry key exists
117 static bool KeyExists(WXHKEY hRootKey
, const char *szKey
);
119 // combines value and key name (uses static buffer!)
120 static const char *GetFullName(const wxRegKey
*pKey
,
121 const char *szValue
= NULL
);
123 // ============================================================================
124 // implementation of wxRegKey class
125 // ============================================================================
127 // ----------------------------------------------------------------------------
128 // static functions and variables
129 // ----------------------------------------------------------------------------
131 const size_t wxRegKey::nStdKeys
= WXSIZEOF(aStdKeys
);
133 // @@ should take a `StdKey key', but as it's often going to be used in loops
134 // it would require casts in user code.
135 const char *wxRegKey::GetStdKeyName(size_t key
)
137 // return empty string if key is invalid
138 wxCHECK_MSG( key
< nStdKeys
, "", "invalid key in wxRegKey::GetStdKeyName" );
140 return aStdKeys
[key
].szName
;
143 const char *wxRegKey::GetStdKeyShortName(size_t key
)
145 // return empty string if key is invalid
146 wxCHECK( key
< nStdKeys
, "" );
148 return aStdKeys
[key
].szShortName
;
151 wxRegKey::StdKey
wxRegKey::ExtractKeyName(wxString
& strKey
)
153 wxString strRoot
= strKey
.Left(REG_SEPARATOR
);
157 for ( ui
= 0; ui
< nStdKeys
; ui
++ ) {
158 if ( strRoot
.CmpNoCase(aStdKeys
[ui
].szName
) == 0 ||
159 strRoot
.CmpNoCase(aStdKeys
[ui
].szShortName
) == 0 ) {
160 hRootKey
= aStdKeys
[ui
].hkey
;
165 if ( ui
== nStdKeys
) {
166 wxFAIL_MSG("invalid key prefix in wxRegKey::ExtractKeyName.");
168 hRootKey
= HKEY_CLASSES_ROOT
;
171 strKey
= strKey
.After(REG_SEPARATOR
);
172 if ( !strKey
.IsEmpty() && strKey
.Last() == REG_SEPARATOR
)
173 strKey
.Truncate(strKey
.Len() - 1);
176 return (wxRegKey::StdKey
)(int)hRootKey
;
179 wxRegKey::StdKey
wxRegKey::GetStdKeyFromHkey(WXHKEY hkey
)
181 for ( size_t ui
= 0; ui
< nStdKeys
; ui
++ ) {
182 if ( (int) aStdKeys
[ui
].hkey
== (int) hkey
)
186 wxFAIL_MSG("non root hkey passed to wxRegKey::GetStdKeyFromHkey.");
191 // ----------------------------------------------------------------------------
193 // ----------------------------------------------------------------------------
198 m_hRootKey
= (WXHKEY
) aStdKeys
[HKCR
].hkey
;
202 wxRegKey::wxRegKey(const wxString
& strKey
) : m_strKey(strKey
)
204 m_hRootKey
= (WXHKEY
) aStdKeys
[ExtractKeyName(m_strKey
)].hkey
;
209 // parent is a predefined (and preopened) key
210 wxRegKey::wxRegKey(StdKey keyParent
, const wxString
& strKey
) : m_strKey(strKey
)
212 RemoveTrailingSeparator(m_strKey
);
213 m_hRootKey
= (WXHKEY
) aStdKeys
[keyParent
].hkey
;
218 // parent is a normal regkey
219 wxRegKey::wxRegKey(const wxRegKey
& keyParent
, const wxString
& strKey
)
220 : m_strKey(keyParent
.m_strKey
)
222 // combine our name with parent's to get the full name
223 if ( !m_strKey
.IsEmpty() &&
224 (strKey
.IsEmpty() || strKey
[0] != REG_SEPARATOR
) ) {
225 m_strKey
+= REG_SEPARATOR
;
229 RemoveTrailingSeparator(m_strKey
);
231 m_hRootKey
= keyParent
.m_hRootKey
;
236 // dtor closes the key releasing system resource
237 wxRegKey::~wxRegKey()
242 // ----------------------------------------------------------------------------
243 // change the key name/hkey
244 // ----------------------------------------------------------------------------
246 // set the full key name
247 void wxRegKey::SetName(const wxString
& strKey
)
252 m_hRootKey
= (WXHKEY
) aStdKeys
[ExtractKeyName(m_strKey
)].hkey
;
255 // the name is relative to the parent key
256 void wxRegKey::SetName(StdKey keyParent
, const wxString
& strKey
)
261 RemoveTrailingSeparator(m_strKey
);
262 m_hRootKey
= (WXHKEY
) aStdKeys
[keyParent
].hkey
;
265 // the name is relative to the parent key
266 void wxRegKey::SetName(const wxRegKey
& keyParent
, const wxString
& strKey
)
270 // combine our name with parent's to get the full name
271 m_strKey
= keyParent
.m_strKey
;
272 if ( !strKey
.IsEmpty() && strKey
[0] != REG_SEPARATOR
)
273 m_strKey
+= REG_SEPARATOR
;
276 RemoveTrailingSeparator(m_strKey
);
278 m_hRootKey
= keyParent
.m_hRootKey
;
281 // hKey should be opened and will be closed in wxRegKey dtor
282 void wxRegKey::SetHkey(WXHKEY hKey
)
289 // ----------------------------------------------------------------------------
290 // info about the key
291 // ----------------------------------------------------------------------------
293 // returns TRUE if the key exists
294 bool wxRegKey::Exists() const
296 // opened key has to exist, try to open it if not done yet
297 return IsOpened() ? TRUE
: KeyExists(m_hRootKey
, m_strKey
);
300 // returns the full name of the key (prefix is abbreviated if bShortPrefix)
301 wxString
wxRegKey::GetName(bool bShortPrefix
) const
303 StdKey key
= GetStdKeyFromHkey((StdKey
) m_hRootKey
);
304 wxString str
= bShortPrefix
? aStdKeys
[key
].szShortName
305 : aStdKeys
[key
].szName
;
306 if ( !m_strKey
.IsEmpty() )
307 str
<< "\\" << m_strKey
;
313 bool wxRegKey::GetKeyInfo(size_t* pnSubKeys
,
316 size_t* pnMaxValueLen
) const
318 bool wxRegKey::GetKeyInfo(ulong
*pnSubKeys
,
321 ulong
*pnMaxValueLen
) const
325 m_dwLastError
= ::RegQueryInfoKey
329 NULL
, // (ptr to) size of class name buffer
331 pnSubKeys
, // [out] number of subkeys
332 pnMaxKeyLen
, // [out] max length of a subkey name
333 NULL
, // longest subkey class name
334 pnValues
, // [out] number of values
335 pnMaxValueLen
, // [out] max length of a value name
336 NULL
, // longest value data
337 NULL
, // security descriptor
338 NULL
// time of last modification
341 if ( m_dwLastError
!= ERROR_SUCCESS
) {
342 wxLogSysError(m_dwLastError
, _("can't get info about registry key '%s'"),
349 wxFAIL_MSG("GetKeyInfo() not implemented");
355 // ----------------------------------------------------------------------------
357 // ----------------------------------------------------------------------------
359 // opens key (it's not an error to call Open() on an already opened key)
360 bool wxRegKey::Open()
366 m_dwLastError
= RegOpenKey((HKEY
) m_hRootKey
, m_strKey
, &tmpKey
);
367 if ( m_dwLastError
!= ERROR_SUCCESS
) {
368 wxLogSysError(m_dwLastError
, _("can't open registry key '%s'"),
374 m_hKey
= (WXHKEY
) tmpKey
;
379 // creates key, failing if it exists and !bOkIfExists
380 bool wxRegKey::Create(bool bOkIfExists
)
382 // check for existence only if asked (i.e. order is important!)
383 if ( !bOkIfExists
&& Exists() ) {
391 m_dwLastError
= RegCreateKey((HKEY
) m_hRootKey
, m_strKey
, &tmpKey
);
392 if ( m_dwLastError
!= ERROR_SUCCESS
) {
393 wxLogSysError(m_dwLastError
, _("can't create registry key '%s'"),
399 m_hKey
= (WXHKEY
) tmpKey
;
404 // close the key, it's not an error to call it when not opened
405 bool wxRegKey::Close()
408 m_dwLastError
= RegCloseKey((HKEY
) m_hKey
);
409 if ( m_dwLastError
!= ERROR_SUCCESS
) {
410 wxLogSysError(m_dwLastError
, _("can't close registry key '%s'"),
424 // ----------------------------------------------------------------------------
425 // delete keys/values
426 // ----------------------------------------------------------------------------
427 bool wxRegKey::DeleteSelf()
432 // it already doesn't exist - ok!
437 // we can't delete keys while enumerating because it confuses GetNextKey, so
438 // we first save the key names and then delete them all
439 wxArrayString astrSubkeys
;
443 bool bCont
= GetFirstKey(strKey
, lIndex
);
445 astrSubkeys
.Add(strKey
);
447 bCont
= GetNextKey(strKey
, lIndex
);
450 size_t nKeyCount
= astrSubkeys
.Count();
451 for ( size_t nKey
= 0; nKey
< nKeyCount
; nKey
++ ) {
452 wxRegKey
key(*this, astrSubkeys
[nKey
]);
453 if ( !key
.DeleteSelf() )
457 // now delete this key itself
460 m_dwLastError
= RegDeleteKey((HKEY
) m_hRootKey
, m_strKey
);
461 if ( m_dwLastError
!= ERROR_SUCCESS
) {
462 wxLogSysError(m_dwLastError
, _("can't delete key '%s'"),
470 bool wxRegKey::DeleteKey(const char *szKey
)
475 wxRegKey
key(*this, szKey
);
476 return key
.DeleteSelf();
479 bool wxRegKey::DeleteValue(const char *szValue
)
485 m_dwLastError
= RegDeleteValue((HKEY
) m_hKey
, szValue
);
486 if ( m_dwLastError
!= ERROR_SUCCESS
) {
487 wxLogSysError(m_dwLastError
, _("can't delete value '%s' from key '%s'"),
488 szValue
, GetName().c_str());
492 // named registry values don't exist in Win16 world
493 wxASSERT( IsEmpty(szValue
) );
495 // just set the (default and unique) value of the key to ""
496 m_dwLastError
= RegSetValue((HKEY
) m_hKey
, NULL
, REG_SZ
, "", RESERVED
);
497 if ( m_dwLastError
!= ERROR_SUCCESS
) {
498 wxLogSysError(m_dwLastError
, _("can't delete value of key '%s'"),
507 // ----------------------------------------------------------------------------
508 // access to values and subkeys
509 // ----------------------------------------------------------------------------
511 // return TRUE if value exists
512 bool wxRegKey::HasValue(const char *szValue
) const
514 // this function should be silent, so suppress possible messages from Open()
518 if ( CONST_CAST
Open() ) {
519 return RegQueryValueEx((HKEY
) m_hKey
, szValue
, RESERVED
,
520 NULL
, NULL
, NULL
) == ERROR_SUCCESS
;
525 // only unnamed value exists
526 return IsEmpty(szValue
);
530 // returns TRUE if this key has any subkeys
531 bool wxRegKey::HasSubkeys() const
533 // just call GetFirstKey with dummy parameters
536 return CONST_CAST
GetFirstKey(str
, l
);
539 // returns TRUE if given subkey exists
540 bool wxRegKey::HasSubKey(const char *szKey
) const
542 if ( CONST_CAST
Open() )
543 return KeyExists(m_hKey
, szKey
);
548 wxRegKey::ValueType
wxRegKey::GetValueType(const char *szValue
)
555 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
, szValue
, RESERVED
,
556 &dwType
, NULL
, NULL
);
557 if ( m_dwLastError
!= ERROR_SUCCESS
) {
558 wxLogSysError(m_dwLastError
, _("can't read value of key '%s'"),
563 return (ValueType
)dwType
;
565 return IsEmpty(szValue
) ? Type_String
: Type_None
;
570 bool wxRegKey::SetValue(const char *szValue
, long lValue
)
572 if ( CONST_CAST
Open() ) {
573 m_dwLastError
= RegSetValueEx((HKEY
) m_hKey
, szValue
, RESERVED
, REG_DWORD
,
574 (RegString
)&lValue
, sizeof(lValue
));
575 if ( m_dwLastError
== ERROR_SUCCESS
)
579 wxLogSysError(m_dwLastError
, _("can't set value of '%s'"),
580 GetFullName(this, szValue
));
584 bool wxRegKey::QueryValue(const char *szValue
, long *plValue
) const
586 if ( CONST_CAST
Open() ) {
587 DWORD dwType
, dwSize
= sizeof(DWORD
);
588 RegString pBuf
= (RegString
)plValue
;
589 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
, szValue
, RESERVED
,
590 &dwType
, pBuf
, &dwSize
);
591 if ( m_dwLastError
!= ERROR_SUCCESS
) {
592 wxLogSysError(m_dwLastError
, _("can't read value of key '%s'"),
597 // check that we read the value of right type
598 wxASSERT_MSG( dwType
== REG_DWORD
,
599 "Type mismatch in wxRegKey::QueryValue()." );
610 bool wxRegKey::QueryValue(const char *szValue
, wxString
& strValue
) const
612 if ( CONST_CAST
Open() ) {
614 // first get the type and size of the data
615 DWORD dwType
, dwSize
;
616 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
, szValue
, RESERVED
,
617 &dwType
, NULL
, &dwSize
);
618 if ( m_dwLastError
== ERROR_SUCCESS
) {
619 RegString pBuf
= (RegString
)strValue
.GetWriteBuf(dwSize
);
620 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
, szValue
, RESERVED
,
621 &dwType
, pBuf
, &dwSize
);
622 strValue
.UngetWriteBuf();
623 if ( m_dwLastError
== ERROR_SUCCESS
) {
624 // check that it was the right type
625 wxASSERT_MSG( dwType
== REG_SZ
,
626 "Type mismatch in wxRegKey::QueryValue()." );
632 // named registry values don't exist in Win16
633 wxASSERT( IsEmpty(szValue
) );
635 m_dwLastError
= RegQueryValue((HKEY
) m_hKey
, 0, strValue
.GetWriteBuf(256), &l
);
636 strValue
.UngetWriteBuf();
637 if ( m_dwLastError
== ERROR_SUCCESS
)
642 wxLogSysError(m_dwLastError
, _("can't read value of '%s'"),
643 GetFullName(this, szValue
));
647 bool wxRegKey::SetValue(const char *szValue
, const wxString
& strValue
)
649 if ( CONST_CAST
Open() ) {
651 m_dwLastError
= RegSetValueEx((HKEY
) m_hKey
, szValue
, RESERVED
, REG_SZ
,
652 (RegString
)strValue
.c_str(),
654 if ( m_dwLastError
== ERROR_SUCCESS
)
657 // named registry values don't exist in Win16
658 wxASSERT( IsEmpty(szValue
) );
660 m_dwLastError
= RegSetValue((HKEY
) m_hKey
, NULL
, REG_SZ
, strValue
, NULL
);
661 if ( m_dwLastError
== ERROR_SUCCESS
)
666 wxLogSysError(m_dwLastError
, _("can't set value of '%s'"),
667 GetFullName(this, szValue
));
671 wxRegKey::operator wxString() const
674 QueryValue(NULL
, str
);
678 // ----------------------------------------------------------------------------
680 // NB: all these functions require an index variable which allows to have
681 // several concurrently running indexations on the same key
682 // ----------------------------------------------------------------------------
684 bool wxRegKey::GetFirstValue(wxString
& strValueName
, long& lIndex
)
690 return GetNextValue(strValueName
, lIndex
);
693 bool wxRegKey::GetNextValue(wxString
& strValueName
, long& lIndex
) const
695 wxASSERT( IsOpened() );
697 // are we already at the end of enumeration?
702 char szValueName
[1024]; // @@ use RegQueryInfoKey...
703 DWORD dwValueLen
= WXSIZEOF(szValueName
);
706 m_dwLastError
= RegEnumValue((HKEY
) m_hKey
, lIndex
,
707 szValueName
, &dwValueLen
,
710 NULL
, // [out] buffer for value
711 NULL
); // [i/o] it's length
713 if ( m_dwLastError
!= ERROR_SUCCESS
) {
714 if ( m_dwLastError
== ERROR_NO_MORE_ITEMS
) {
715 m_dwLastError
= ERROR_SUCCESS
;
719 wxLogSysError(m_dwLastError
, _("can't enumerate values of key '%s'"),
726 strValueName
= szValueName
;
728 // only one unnamed value
729 wxASSERT( lIndex
== 0 );
732 strValueName
.Empty();
738 bool wxRegKey::GetFirstKey(wxString
& strKeyName
, long& lIndex
)
744 return GetNextKey(strKeyName
, lIndex
);
747 bool wxRegKey::GetNextKey(wxString
& strKeyName
, long& lIndex
) const
749 wxASSERT( IsOpened() );
751 // are we already at the end of enumeration?
755 char szKeyName
[_MAX_PATH
+ 1];
756 m_dwLastError
= RegEnumKey((HKEY
) m_hKey
, lIndex
++, szKeyName
, WXSIZEOF(szKeyName
));
758 if ( m_dwLastError
!= ERROR_SUCCESS
) {
759 if ( m_dwLastError
== ERROR_NO_MORE_ITEMS
) {
760 m_dwLastError
= ERROR_SUCCESS
;
764 wxLogSysError(m_dwLastError
, _("can't enumerate subkeys of key '%s'"),
771 strKeyName
= szKeyName
;
775 // ============================================================================
776 // implementation of global private functions
777 // ============================================================================
778 bool KeyExists(WXHKEY hRootKey
, const char *szKey
)
781 if ( RegOpenKey( (HKEY
) hRootKey
, szKey
, &hkeyDummy
) == ERROR_SUCCESS
) {
782 RegCloseKey(hkeyDummy
);
789 const char *GetFullName(const wxRegKey
*pKey
, const char *szValue
)
791 static wxString s_str
;
792 s_str
= pKey
->GetName();
793 if ( !IsEmpty(szValue
) )
794 s_str
<< "\\" << szValue
;
796 return s_str
.c_str();
799 void RemoveTrailingSeparator(wxString
& str
)
801 if ( !str
.IsEmpty() && str
.Last() == REG_SEPARATOR
)
802 str
.Truncate(str
.Len() - 1);
805 // ============================================================================
806 // global public functions
807 // ============================================================================
809 bool GetExtensionFromMimeType(wxString
*pExt
, const wxString
& strMimeType
)
811 // @@@ VZ: I don't know of any official documentation which mentions this
812 // location, but as a matter of fact IE uses it, so why not we?
813 static const char *szMimeDbase
= "MIME\\Database\\Content Type\\";
815 wxString strKey
= szMimeDbase
;
816 strKey
<< strMimeType
;
818 // suppress possible error messages
820 wxRegKey
key(wxRegKey::HKCR
, strKey
);
822 if ( key
.QueryValue("Extension", *pExt
) )
826 // no such MIME type or no extension for it
830 bool GetMimeTypeFromExtension(wxString
*pMimeType
, const wxString
& strExt
)
832 wxCHECK( !strExt
.IsEmpty(), FALSE
);
834 // add the leading point if necessary
836 if ( strExt
[0] != '.' ) {
841 // suppress possible error messages
843 wxRegKey
key(wxRegKey::HKCR
, str
);
845 if ( key
.QueryValue("Content Type", *pMimeType
) )
849 // no such extension or no content-type
853 bool GetFileTypeFromExtension(wxString
*pFileType
, const wxString
& strExt
)
855 wxCHECK( !strExt
.IsEmpty(), FALSE
);
857 // add the leading point if necessary
859 if ( strExt
[0] != '.' ) {
864 // suppress possible error messages
866 wxRegKey
key(wxRegKey::HKCR
, str
);
868 if ( key
.QueryValue("", *pFileType
) ) // it's the default value of the key
872 // no such extension or no value
876 bool GetFileTypeIcon(wxIcon
*pIcon
, const wxString
& strFileType
)
878 wxCHECK( !strFileType
.IsEmpty(), FALSE
);
881 strIconKey
<< strFileType
<< REG_SEPARATOR
<< "DefaultIcon";
883 // suppress possible error messages
885 wxRegKey
key(wxRegKey::HKCR
, strIconKey
);
889 if ( key
.QueryValue("", strIcon
) ) { // it's the default value of the key
890 // the format is the following: <full path to file>, <icon index>
891 // NB: icon index may be negative as well as positive and the full path
892 // may contain the environment variables inside '%'
893 wxString strFullPath
= strIcon
.Before(','),
894 strIndex
= strIcon
.Right(',');
896 // index may be omitted, in which case Before(',') is empty and
897 // Right(',') is the whole string
898 if ( strFullPath
.IsEmpty() ) {
899 strFullPath
= strIndex
;
903 wxString strExpPath
= wxExpandEnvVars(strFullPath
);
904 int nIndex
= atoi(strIndex
);
906 HICON hIcon
= ExtractIcon(GetModuleHandle(NULL
), strExpPath
, nIndex
);
907 switch ( (int)hIcon
) {
908 case 0: // means no icons were found
909 case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/...
910 wxLogDebug("incorrect registry entry '%s': no such icon.",
915 pIcon
->SetHICON((WXHICON
)hIcon
);
921 // no such file type or no value or incorrect icon entry
925 bool GetFileTypeDescription(wxString
*pDesc
, const wxString
& strFileType
)
927 wxCHECK( !strFileType
.IsEmpty(), FALSE
);
929 // suppress possible error messages
931 wxRegKey
key(wxRegKey::HKCR
, strFileType
);
934 if ( key
.QueryValue("", *pDesc
) ) // it's the default value of the key
938 // no such file type or no value