How to obtain default icons 
Author Message
 How to obtain default icons

Hi.

 Does anyone know how to get the default icon for an extension
(such as *.txt, *.html, ...)?

 I am now trying to make an FTP application, something like
FTPExplorer. I want to show the files on FTP server by icons.
For example, if there is test.txt on server, I would like it
to be shown by the default icon for *.txt file given on a
client Windows PC. To do this, I need to know the list
that is shown by VIEW|Option|File Type menu on explorer.
But I do not know how to do this.
  I know I can obtain the icon for an existing file by using
SHGetFileInfo and that I can obtain the system imagelist
by using this API. But I cannot find how to get the
relation between the order of images in the system imagelist
and extensions.

 Any help would be appreciated.

 Thanks in advance.

 Arita



Sat, 30 Dec 2000 03:00:00 GMT  
 How to obtain default icons
programmatically open registry
under HKEY_CLASSES_ROOT go to the extension you are looking for there will
be a default value for example for .bmp file it may be Paint.Picture. now
navigate to that key (Paint.Picture) in HKEY_CLASSES_ROOT  and you would
find a entry called DefaultIcon the value for it will contain the default
icon value, in this case mspaint.exe, 1
There may be an easier way which I amy not be aware of.

--
-------------------------------------------------------
Rajesh Parikh
Microsoft Certified Solution Developer

-------------------------------------------------------

Quote:

>Hi.

> Does anyone know how to get the default icon for an extension
>(such as *.txt, *.html, ...)?

> I am now trying to make an FTP application, something like
>FTPExplorer. I want to show the files on FTP server by icons.
>For example, if there is test.txt on server, I would like it
>to be shown by the default icon for *.txt file given on a
>client Windows PC. To do this, I need to know the list
>that is shown by VIEW|Option|File Type menu on explorer.
>But I do not know how to do this.
>  I know I can obtain the icon for an existing file by using
>SHGetFileInfo and that I can obtain the system imagelist
>by using this API. But I cannot find how to get the
>relation between the order of images in the system imagelist
>and extensions.

> Any help would be appreciated.

> Thanks in advance.

> Arita



Sat, 30 Dec 2000 03:00:00 GMT  
 How to obtain default icons

Quote:

> programmatically open registry
> under HKEY_CLASSES_ROOT go to the extension you are looking for there will
> be a default value for example for .bmp file it may be Paint.Picture. now
> navigate to that key (Paint.Picture) in HKEY_CLASSES_ROOT  and you would
> find a entry called DefaultIcon the value for it will contain the default
> icon value, in this case mspaint.exe, 1
> There may be an easier way which I amy not be aware of.

Call ExtractAssociatedIcon().
Quote:
> --
> -------------------------------------------------------
> Rajesh Parikh
> Microsoft Certified Solution Developer

> -------------------------------------------------------

> >Hi.

> > Does anyone know how to get the default icon for an extension
> >(such as *.txt, *.html, ...)?

> > I am now trying to make an FTP application, something like
> >FTPExplorer. I want to show the files on FTP server by icons.
> >For example, if there is test.txt on server, I would like it
> >to be shown by the default icon for *.txt file given on a
> >client Windows PC. To do this, I need to know the list
> >that is shown by VIEW|Option|File Type menu on explorer.
> >But I do not know how to do this.
> >  I know I can obtain the icon for an existing file by using
> >SHGetFileInfo and that I can obtain the system imagelist
> >by using this API. But I cannot find how to get the
> >relation between the order of images in the system imagelist
> >and extensions.

> > Any help would be appreciated.

> > Thanks in advance.

> > Arita



Sat, 30 Dec 2000 03:00:00 GMT  
 How to obtain default icons
The trouble with the registry->DefaultIcon way is that it sometimes not as
obvious as it may seem: The number that comes after the EXE/DLL file name
might be a negative number, and then it's a resource ID and so on.
Use SHGetFileInfo() with the appropriate masks to get the associated icon -
Large AND Small one.
There's a MS knowledge base article showing this techniqe.

Quote:


>> programmatically open registry
>> under HKEY_CLASSES_ROOT go to the extension you are looking for there
will
>> be a default value for example for .bmp file it may be Paint.Picture. now
>> navigate to that key (Paint.Picture) in HKEY_CLASSES_ROOT  and you would
>> find a entry called DefaultIcon the value for it will contain the default
>> icon value, in this case mspaint.exe, 1
>> There may be an easier way which I amy not be aware of.

>Call ExtractAssociatedIcon().

>> --
>> -------------------------------------------------------
>> Rajesh Parikh
>> Microsoft Certified Solution Developer

>> -------------------------------------------------------



Sat, 30 Dec 2000 03:00:00 GMT  
 How to obtain default icons
Use SHGetFileInfo()

--
* - * - * - * - *
Matt Gallant
Aylmer, Ontario Canada

To "meet" me, check out my homepage: http://www.kanservu.ca/~gallantm.

Quote:

>programmatically open registry
>under HKEY_CLASSES_ROOT go to the extension you are looking for there will
>be a default value for example for .bmp file it may be Paint.Picture. now
>navigate to that key (Paint.Picture) in HKEY_CLASSES_ROOT  and you would
>find a entry called DefaultIcon the value for it will contain the default
>icon value, in this case mspaint.exe, 1
>There may be an easier way which I amy not be aware of.

>--
>-------------------------------------------------------
>Rajesh Parikh
>Microsoft Certified Solution Developer

>-------------------------------------------------------

>>Hi.

>> Does anyone know how to get the default icon for an extension
>>(such as *.txt, *.html, ...)?

>> I am now trying to make an FTP application, something like
>>FTPExplorer. I want to show the files on FTP server by icons.
>>For example, if there is test.txt on server, I would like it
>>to be shown by the default icon for *.txt file given on a
>>client Windows PC. To do this, I need to know the list
>>that is shown by VIEW|Option|File Type menu on explorer.
>>But I do not know how to do this.
>>  I know I can obtain the icon for an existing file by using
>>SHGetFileInfo and that I can obtain the system imagelist
>>by using this API. But I cannot find how to get the
>>relation between the order of images in the system imagelist
>>and extensions.

>> Any help would be appreciated.

>> Thanks in advance.

>> Arita



Sat, 30 Dec 2000 03:00:00 GMT  
 How to obtain default icons
Hi,

 Thanks for useful tips, everyone. I still have several problems.

1.How can I obtain the icon for a file that does not have
an extension (like directory, MyComputer, CD-Rom, Control Panel etc.)
I found "Directory" key but it just gives the icon when a folder is
closed:`
and there is no key such as openDirectory, CD-ROM, MyComputer etc.
The fourth icon in shell32.dll is the icon for open folder in my PC
but is this always the fourth icon for any machine?

2.How can I get the default icon for unknown extensions?
 For unknown extension, it seems that the first image in shell32.dll
is the default icon. But I am not sure if this is always the case.

3.I looked into exefile key but just "%1" is written in  it.
How can I understand this?

4.And if I use SHGetFileInfo to obtain imagelist, what does the order in
the
imagelist mean? It does not seem to be exactly the same as shell32.dll.

Quote:

>Use SHGetFileInfo()

Could you give me a detail what to do?
As I have written in the original post, I know I can get the
icon for an existing file with this API. But what I want
to do is to know the default icon for an extension.
(Since I am trying to make an FTP application, files on
the server do not exist on the client.)
If I can do it just by using SHGetFileInfo, it is the best for me.

Quote:
>Fredrik Blom wrote
>* Returned value (should be handle to thge imagelist, right?) is 1
>regardless of whether I want the large or small icons...
>* The iIcon member of the SHFILEINFO returns with the same value when
>getting info for "config.sys" files and "autoexec.bat" (and for ".zip"-files
>when I pathced the MS sample a bit)...

Both work fine for me. Returned images are large (small) icons
if I give LARGEICON (SMALLICON) in the last parameter.
And the iIcon number is for "c:\config.sys" is different
from "c:\autoexec.bat".

Arita



Sun, 31 Dec 2000 03:00:00 GMT  
 How to obtain default icons
Hi Arita and others reading this thread,

I'm going to try and answer here what I can, based on my understanding of the subject.  I wish to say that I haven't had much experience in this per se, except that I'm spent the last little while trying to understand more about COM.  It has lead me to topics such as shell extensions and the like, so some of it may apply here.
--
* - * - * - * - *
Matt Gallant
Aylmer, Ontario Canada

To "meet" me, check out my homepage: http://www.kanservu.ca/~gallantm.

Quote:

>Hi,

> Thanks for useful tips, everyone. I still have several problems.

>1.How can I obtain the icon for a file that does not have
>an extension (like directory, MyComputer, CD-Rom, Control Panel etc.)

Well, you could go around the registry trying to patch this stuff together, but it's a lot of bother.  Also, it probably won't work in all cases.  From my reading about shell extensions, I've learned that "icon handlers" can be installed in the system that the shell uses when deciding what icon is used.  In other words, some extensions may not register an icon, but rather, an icon extension that decides programmatically what icon should be displayed.  The programmer of the extension could decide that for files of his type, the icon could change depending on the content of the file (i.e. the icon extension would examine those files specifically), or the time of the day that the file was last written.  All of this information is provided to the shell by predefined COM interfaces.

SHGetFileInfo() can be used to get directory and drive icons... just use the path name (i.e "A:\").  I'll mention more on this later.  For the other stuff, you'll most likely need to use COM.  You see, all of these "objects" exist in a large NAMESPACE the starts at the Desktop level and opens up into further levels.  These levels obviously include BUT ARE NOT LIMITED TO actual files and directories on your storage devices.  This is where fetching icons become complex.  The "extra" icons (i.e. Network Neighborhood, Control Panel, Recycle Bin) are special and are provided by different components automatically or through the registry.  And consider, shortcuts... the extension is LNK, but they don't all have the same icons.  The problem is that there are too many places in the registry to consider when trying to track this down.  So, the key is to get them the way that the shell does: by using COM objects which expose IShellFolder interfaces.

IShellFolder is the COM representation of a folder in a namespace.  Folder, in this context, is not limited to directories... it is any object that "contains" any other shell objects.  The Desktop itself represents the root of the system's namespace, and there is a specific call to get the IShellFolder interface to the desktop:  SHGetDesktopFolder().  From this interface, you can transverse the different levels.  There is a method, IShellFolder::BindToObject, that returns the IShellFolder for a "subfolder".  The IShellFolder::GetUIObjectOf will give you interfaces to objects within the folder.  This method can return interfaces for extracting icons, but it can also be used to return the context menu for the object (the menu presented when you right-click on the icon).  You'd be interested in the first case, so you'd request the method to return you an IExtractIcon interface which will give you the location and index of the icon by calling its GetIconLocation method, or just use its second method Extract, which will just give you the icons as HICONs.  When you examine the parameters of these methods, it would not be unreasonable to assume that SHGetFileInfo() uses IShellFolder interfaces to get the icon information.

Of course, if you aren't familiar with COM, there's going to be a bit of reading to do to figure out how to make use of all of this stuff.  Unfortunately, or fortunately depending on your P.O.V. , all of Microsoft's new technologies are COM based... you can't avoid it much longer.  I can try and help you, or anyone else, out more if you get stuck.

Quote:
>I found "Directory" key but it just gives the icon when a folder is
>closed:`
>and there is no key such as openDirectory, CD-ROM, MyComputer etc.

For folders, this isn't a problem.  There is a flag for SHGetFileInfo to return the "opened" icon, because closed is the default.  The flag is SHGFI_OPENICON.  Just OR it with your other flags.

Quote:
>The fourth icon in shell32.dll is the icon for open folder in my PC
>but is this always the fourth icon for any machine?

Well, with Windows, these kind of assumptions are not good to rely on.

The beauty of IShellFolder, is that it doesn't matter where the objects in the namespace come from... you get an IShellFolder that you use in a standard way from whatever software in the system is responsible for that portion of the namespace.  Obviously, SHELL32.DLL provides IShellFolder support for most of the file system and the operating system "extensions"... i.e. Control Panel, Net Neighborhood.  And, it uses the icon resources in SHELL32.DLL to do it.  But they could come from anyware... remember, the user can customize some of these icons!  If you truly want to give the system "look and feel", it's better to let the system tell you what icon it would use.  This is where IShellFolder comes into the picture.

Quote:
>2.How can I get the default icon for unknown extensions?
> For unknown extension, it seems that the first image in shell32.dll
>is the default icon. But I am not sure if this is always the case.

Again, not a good assumption to make.  What I would do is:

1.  Create a temporary (0-length) file with an extension that would probably never be registered.
2.  Ask SHGetFileInfo() what icon it would use.
3.  If you need, cache this information for all "unknown" extensions.
4.  Delete the temporary file.

What do I mean, by step 1?  Well, be outrageous.  Use a file name like "0.~unlikely_extension".  Remember... nice thing about Win32 file systems... extensions can be any length, and what application will ever register "~unlikely_extension" for itself.

This technique could also be available to the person who is writing the FTP client.  You could use the file name(s) from the server to create temporary files with the same names on the local machine and then using SHGetFileInfo on the temporary file(s).  Of course, I don't know off hand what the performance would be like, given all the extra file I/O involved in creating and deleting the temporary files, but it's an idea.

Quote:
>3.I looked into exefile key but just "%1" is written in  it.
>How can I understand this?

>4.And if I use SHGetFileInfo to obtain imagelist, what does the order in
>the
>imagelist mean? It does not seem to be exactly the same as shell32.dll.

Again, the order should not be counted upon.  The "system imagelist" is most likely a cache that the system builds, either at startup, or as it encounters new icons.  A program, like the shell (EXPLORER.EXE), could conceivable keep an internal table of all "known" extensions on the system.  As it builds this table, it adds the icon to the imagelist, and adds an entry in its table containing the extension and the index of the associated icon.  Then, it would just need to lookup the extension in the internal table to get the index.  If this kind of scheme where used, the icon order in the imagelist would be unpredicatable, to say the least.
Quote:


>>Use SHGetFileInfo()
>Could you give me a detail what to do?
>As I have written in the original post, I know I can get the
>icon for an existing file with this API. But what I want
>to do is to know the default icon for an extension.
>(Since I am trying to make an FTP application, files on
>the server do not exist on the client.)
>If I can do it just by using SHGetFileInfo, it is the best for me.

>>Fredrik Blom wrote
>>* Returned value (should be handle to thge imagelist, right?) is 1
>>regardless of whether I want the large or small icons...
>>* The iIcon member of the SHFILEINFO returns with the same value when
>>getting info for "config.sys" files and "autoexec.bat" (and for ".zip"-files
>>when I pathced the MS sample a bit)...
>Both work fine for me. Returned images are large (small) icons
>if I give LARGEICON (SMALLICON) in the last parameter.
>And the iIcon number is for "c:\config.sys" is different
>from "c:\autoexec.bat".

>Arita



Sun, 31 Dec 2000 03:00:00 GMT  
 How to obtain default icons
Hi Arita and others reading this thread,

I'm going to try and answer here what I can, based on my understanding of the subject.  I wish to say that I haven't had much experience in this per se, except that I'm spent the last little while trying to understand more about COM.  It has lead me to topics such as shell extensions and the like, so some of it may apply here.
--
* - * - * - * - *
Matt Gallant
Aylmer, Ontario Canada

To "meet" me, check out my homepage: http://www.kanservu.ca/~gallantm.

Quote:

>Hi,

> Thanks for useful tips, everyone. I still have several problems.

>1.How can I obtain the icon for a file that does not have
>an extension (like directory, MyComputer, CD-Rom, Control Panel etc.)

Well, you could go around the registry trying to patch this stuff together, but it's a lot of bother.  Also, it probably won't work in all cases.  From my reading about shell extensions, I've learned that "icon handlers" can be installed in the system that the shell uses when deciding what icon is used.  In other words, some extensions may not register an icon, but rather, an icon extension that decides programmatically what icon should be displayed.  The programmer of the extension could decide that for files of his type, the icon could change depending on the content of the file (i.e. the icon extension would examine those files specifically), or the time of the day that the file was last written.  All of this information is provided to the shell by predefined COM interfaces.

SHGetFileInfo() can be used to get directory and drive icons... just use the path name (i.e "A:\").  I'll mention more on this later.  For the other stuff, you'll most likely need to use COM.  You see, all of these "objects" exist in a large NAMESPACE the starts at the Desktop level and opens up into further levels.  These levels obviously include BUT ARE NOT LIMITED TO actual files and directories on your storage devices.  This is where fetching icons become complex.  The "extra" icons (i.e. Network Neighborhood, Control Panel, Recycle Bin) are special and are provided by different components automatically or through the registry.  And consider, shortcuts... the extension is LNK, but they don't all have the same icons.  The problem is that there are too many places in the registry to consider when trying to track this down.  So, the key is to get them the way that the shell does: by using COM objects which expose IShellFolder interfaces.

IShellFolder is the COM representation of a folder in a namespace.  Folder, in this context, is not limited to directories... it is any object that "contains" any other shell objects.  The Desktop itself represents the root of the system's namespace, and there is a specific call to get the IShellFolder interface to the desktop:  SHGetDesktopFolder().  From this interface, you can transverse the different levels.  There is a method, IShellFolder::BindToObject, that returns the IShellFolder for a "subfolder".  The IShellFolder::GetUIObjectOf will give you interfaces to objects within the folder.  This method can return interfaces for extracting icons, but it can also be used to return the context menu for the object (the menu presented when you right-click on the icon).  You'd be interested in the first case, so you'd request the method to return you an IExtractIcon interface which will give you the location and index of the icon by calling its GetIconLocation method, or just use its second method Extract, which will just give you the icons as HICONs.  When you examine the parameters of these methods, it would not be unreasonable to assume that SHGetFileInfo() uses IShellFolder interfaces to get the icon information.

Of course, if you aren't familiar with COM, there's going to be a bit of reading to do to figure out how to make use of all of this stuff.  Unfortunately, or fortunately depending on your P.O.V. , all of Microsoft's new technologies are COM based... you can't avoid it much longer.  I can try and help you, or anyone else, out more if you get stuck.

Quote:
>I found "Directory" key but it just gives the icon when a folder is
>closed:`
>and there is no key such as openDirectory, CD-ROM, MyComputer etc.

For folders, this isn't a problem.  There is a flag for SHGetFileInfo to return the "opened" icon, because closed is the default.  The flag is SHGFI_OPENICON.  Just OR it with your other flags.

Quote:
>The fourth icon in shell32.dll is the icon for open folder in my PC
>but is this always the fourth icon for any machine?

Well, with Windows, these kind of assumptions are not good to rely on.

The beauty of IShellFolder, is that it doesn't matter where the objects in the namespace come from... you get an IShellFolder that you use in a standard way from whatever software in the system is responsible for that portion of the namespace.  Obviously, SHELL32.DLL provides IShellFolder support for most of the file system and the operating system "extensions"... i.e. Control Panel, Net Neighborhood.  And, it uses the icon resources in SHELL32.DLL to do it.  But they could come from anyware... remember, the user can customize some of these icons!  If you truly want to give the system "look and feel", it's better to let the system tell you what icon it would use.  This is where IShellFolder comes into the picture.

Quote:
>2.How can I get the default icon for unknown extensions?
> For unknown extension, it seems that the first image in shell32.dll
>is the default icon. But I am not sure if this is always the case.

Again, not a good assumption to make.  What I would do is:

1.  Create a temporary (0-length) file with an extension that would probably never be registered.
2.  Ask SHGetFileInfo() what icon it would use.
3.  If you need, cache this information for all "unknown" extensions.
4.  Delete the temporary file.

What do I mean, by step 1?  Well, be outrageous.  Use a file name like "0.~unlikely_extension".  Remember... nice thing about Win32 file systems... extensions can be any length, and what application will ever register "~unlikely_extension" for itself.

This technique could also be available to the person who is writing the FTP client.  You could use the file name(s) from the server to create temporary files with the same names on the local machine and then using SHGetFileInfo on the temporary file(s).  Of course, I don't know off hand what the performance would be like, given all the extra file I/O involved in creating and deleting the temporary files, but it's an idea.

Quote:
>3.I looked into exefile key but just "%1" is written in  it.
>How can I understand this?

>4.And if I use SHGetFileInfo to obtain imagelist, what does the order in
>the
>imagelist mean? It does not seem to be exactly the same as shell32.dll.

Again, the order should not be counted upon.  The "system imagelist" is most likely a cache that the system builds, either at startup, or as it encounters new icons.  A program, like the shell (EXPLORER.EXE), could conceivable keep an internal table of all "known" extensions on the system.  As it builds this table, it adds the icon to the imagelist, and adds an entry in its table containing the extension and the index of the associated icon.  Then, it would just need to lookup the extension in the internal table to get the index.  If this kind of scheme where used, the icon order in the imagelist would be unpredicatable, to say the least.
Quote:


>>Use SHGetFileInfo()
>Could you give me a detail what to do?
>As I have written in the original post, I know I can get the
>icon for an existing file with this API. But what I want
>to do is to know the default icon for an extension.
>(Since I am trying to make an FTP application, files on
>the server do not exist on the client.)
>If I can do it just by using SHGetFileInfo, it is the best for me.

>>Fredrik Blom wrote
>>* Returned value (should be handle to thge imagelist, right?) is 1
>>regardless of whether I want the large or small icons...
>>* The iIcon member of the SHFILEINFO returns with the same value when
>>getting info for "config.sys" files and "autoexec.bat" (and for ".zip"-files
>>when I pathced the MS sample a bit)...
>Both work fine for me. Returned images are large (small) icons
>if I give LARGEICON (SMALLICON) in the last parameter.
>And the iIcon number is for "c:\config.sys" is different
>from "c:\autoexec.bat".

>Arita



Sun, 31 Dec 2000 03:00:00 GMT  
 How to obtain default icons
Hi.


 >Call ExtractAssociatedIcon().


 >The trouble with the registry->DefaultIcon way is that it sometimes
not as
 >obvious as it may seem: The number that comes after the EXE/DLL file
name
 >might be a negative number, and then it's a resource ID and so on.
 >Use SHGetFileInfo() with the appropriate masks to get the associated
icon -
 >Large AND Small one.

Could you give me a detail what to do and/or a source code to do it?
As I have written in the original post, I know I can get the
icon for an existing file with this API. But what I want
to do is to know the default icon for an extension.
(Since I am trying to make an FTP application, files on
the server do not exist on the client.)
If I can do it just by using SHGetFileInfo or ExtractAssociatedIcon,
it is the best for me.
Even if I give *.txt for the 1st parameter of SHGetFileInfo, for
example, it does not return the correct icon when there is no file with
.txt extension.

 >There's a MS knowledge base article showing this techniqe.
Please tell me where I can see it.

Arita



Mon, 01 Jan 2001 03:00:00 GMT  
 How to obtain default icons
On Thu, 16 Jul 1998 21:41:09 +0900, Arita

Quote:

>Even if I give *.txt for the 1st parameter of SHGetFileInfo, for
>example, it does not return the correct icon when there is no file with
>.txt extension.

You probably forgot to pass the SHGFI_USEFILEATTRIBUTES flag.
--
(My return address is intentionally invalid; delete ".---" to get my real address.
My responses are not to be considered official technical support or advice.)


Tue, 02 Jan 2001 03:00:00 GMT  
 How to obtain default icons
If the file does not exist, it is not as straight forward a using the
simple one liner API functions. Try reading the registry ie:

//  lpszType : filename extension
//  bLargeIcon : TRUE is large incon is to returned
//  returns:  HICON for the associated lpszType

HICON CMyApp::GetIconFileType(LPCSTR lpszType, BOOL bLargeIcon)
{
  HICON hIcon = 0;
  const int BUFSIZE = 1024;
  char szReg[BUFSIZE];
  DWORD dwSize = BUFSIZE;
  int nIconIndex = 0;
  char* lpszFileName;
  char* lpszIconIndex;
  HKEY hk;

// For the given extension, get the default regkey associated with it
// ie: ".zip" sets szReg to "WinZip"
  ::RegOpenKeyEx( HKEY_CLASSES_ROOT, lpszType,
    NULL, KEY_QUERY_VALUE, &hk );
  ::RegQueryValueEx( hk, "", NULL, NULL, (byte*)szReg, &dwSize );
  ::RegCloseKey( hk );

// The previous Query has set the dwSize, so reset it
  dwSize = BUFSIZE;

// For associated regkey, get its "DefaultIcon" key, and query
// its default value
// This will return the file that the icon lives in and the icon index
// ie: "c:\this\file.exe,1"
  strcat( szReg, "\\DefaultIcon" );
  ::RegOpenKeyEx( HKEY_CLASSES_ROOT, szReg,
    NULL, KEY_QUERY_VALUE, &hk );
  ::RegQueryValueEx( hk, "", NULL, NULL, (byte*)szReg, &dwSize );
  ::RegCloseKey( hk );

// Parse the string into a filename and icon index
// ie: filename="c:\this\file.exe" iconindex=1
  if ((lpszIconIndex = strchr( szReg, ',' )) != NULL)
  {
    *lpszIconIndex = '\0';
    lpszFileName = szReg;
    nIconIndex = atoi( ++lpszIconIndex );

    // Extract large or small icon from file
    if (bLargeIcon)
      ::ExtractIconEx( lpszFileName, nIconIndex, &hIcon, 0, 1 );
    else
      ::ExtractIconEx( lpszFileName, nIconIndex, 0, &hIcon, 1 );
  }

return hIcon;

Quote:
}



Quote:
>Hi.

> Does anyone know how to get the default icon for an extension
>(such as *.txt, *.html, ...)?

> I am now trying to make an FTP application, something like
>FTPExplorer. I want to show the files on FTP server by icons.
>For example, if there is test.txt on server, I would like it
>to be shown by the default icon for *.txt file given on a
>client Windows PC. To do this, I need to know the list
>that is shown by VIEW|Option|File Type menu on explorer.
>But I do not know how to do this.
>  I know I can obtain the icon for an existing file by using
>SHGetFileInfo and that I can obtain the system imagelist
>by using this API. But I cannot find how to get the
>relation between the order of images in the system imagelist
>and extensions.

> Any help would be appreciated.

> Thanks in advance.

> Arita

--
John
Remove spam entry from my address to email me.


Sat, 06 Jan 2001 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. How to obtain default icons

2. Default Icon Hell: MFC Icon appears even after file and IDR_MAINFRAME changed

3. Q: How to obtain the font info specified for desktop icons

4. Obtaining icons....

5. Rendering of default icon

6. Default Icon

7. TitleBar (and TaskBar) Icon - How do I change the default

8. Setting the default program icon

9. Default icon setting with user defined file extension

10. Console Applications ran from service have default icons???

11. Default Windows icon

12. Help changing the default Icon after/at Compiling?

 

 
Powered by phpBB® Forum Software