 |
|
 |
How to Find a larger icon than "large icon" on this program?
please help me. thanks.
|
|
|
|
 |
|
 |
How can I get application Icon(that we can see in Windows Explower) in C#?
|
|
|
|
 |
|
 |
Hello, This is what I am looking for! But how will I implement this in C#? Can anybody help me? The constant FILE_ATTRIBUTE_NORMAL does not exist.
Please help me here.
Thanks!
|
|
|
|
 |
|
 |
FILE_ATTRIBUTE_NORMAL is zero.
FILE_ATTRIBUTE_NORMAL const win32file.FILE_ATTRIBUTE_NORMAL; The file has no other attributes set. This attribute is valid only if used alone.
otherwise try googleing FILE_ATTRIBUTE_NORMAL , plenty of answers.
|
|
|
|
 |
|
 |
Thank you for your reply. =D
|
|
|
|
 |
|
 |
This was my first time with ShGetFileInfo and this article saved me a good deal of time. So dear .S.Rod., please KMFB*
---------------------- *KMFB - Kiss my furry butt
|
|
|
|
 |
|
 |
I have download the code and run it on Win XP the Larger icon is not shown clear it have black border. Do anybody notice it...can u plz help me out.
|
|
|
|
 |
|
 |
UseShGetFileInfo.h:... #pragma warning( push ) #pragma warning (disable : 4089)
class CUseShGetFileInfo{ private: CUseShGetFileInfo(); public: virtual ~CUseShGetFileInfo(); // not needed static HIMAGELIST GetSystemImageListHandle( BOOL bSmallIcon ); static int GetFileIconIndex( CString strFileName , BOOL bSmallIcon); static int GetDirIconIndex(BOOL bSmallIcon);
static HICON GetFileIconHandle(CString strFileName,BOOL bSmallIcon); static HICON GetFolderIconHandle(BOOL bSmallIcon );
static CString GetFileType(CString strFileName); };
#pragma warning( pop ) UseShGetFileInfo.cpp:#include <shlwapi.h> // path manipulation functions
#pragma comment( lib, "shlwapi" ) #include <objbase.h>
#if defined( _MT ) CoInitializeEx( NULL, COINIT_MULTITHREADED ); #else CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ); #endif HIMAGELIST CUseShGetFileInfo::GetSystemImageListHandle( BOOL bSmallIcon ) { TCHAR tcSystemRoot[MAX_PATH + 1]; GetWindowsDirectory( tcSystemRoot, MAX_PATH ); PathStripToRoot( tcSystemRoot ); HIMAGELIST hSystemImageList; SHFILEINFO ssfi;
if (bSmallIcon) { hSystemImageList = (HIMAGELIST)SHGetFileInfo(tcSystemRoot, 0, &ssfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_ICON); } else { ... }
int CUseShGetFileInfo::GetDirIconIndex(BOOL bSmallIcon ) { SHFILEINFO sfi; if (bSmallIcon) { SHGetFileInfo( _T( "" ), FILE_ATTRIBUTE_DIRECTORY, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES | SHGFI_ICON); } else { ... }
Apply respective changes to all other locations. In particular, supply SHGFI_ICON whenever any SHGFI_XXXICON flag is used, supply UNICODE compatible strings, even if they aren't evaluated by content, don't use a hardcoded C:\ drive.
The class cannot be instantiated anymore, which is an intended effect. The methods are available through CUseShGetFileInfo::GetSystemImageListHandle( BOOL bSmallIcon ) calls, etc., without any instance available -- that's what static members are for.
I've probably overlooked some issues, but this is a start anyway. If you have any criticism concerning the changes let's hear them.
.f
p.s.: Is there a way to apply syntax highlighting in these comments?
|
|
|
|
 |
|
 |
Using the icon handle which we get using SHGetFileInfo, how to save as ico file? I tried using GlobalLock(hicon) to get handle to icon bits and then tried to write it to a file. But it was failing?
Is there is a way to save as a icon file using the handle HICON?
|
|
|
|
 |
|
 |
The answer to your question is CxImage class This class can create an icon file (*.ico) from HICON. You will find the "CxImage" class on this site only Good Luck.
|
|
|
|
 |
|
 |
Is there any way to get the network adapter icon? The icons present in the device manager of windows.
thanks Sri
|
|
|
|
 |
|
 |
and I don't bother what other here say. It was usefull to me even if I don't use the class but only some methods of it. Either way - I learnt some things about shell icons.
|
|
|
|
 |
|
 |
Ditto. I found this useful too. Thanks for posting it!
|
|
|
|
 |
|
 |
Me too! I've been looking through books and websites with no luck trying to figure out how to lookup system icons. Doru's code was a great place to start.
I added a "bOpenIcon" parameter to GetFileIconIndex(), GetDirIconIndex(), GetFileIconHandle(), and GetFolderIconHandle(). If it is true, I add SHGFI_OPENICON to the flags used in the call to SHGetFileInfo(). Just a small improvement to make the tree act more like Windows Explorer.
jaramilr
|
|
|
|
 |
|
 |
I totally agree with .S.Rod. He may have used harsh words, but he is right. Don't you realize that number of such articles increase exponentially. This will make CP less useful in the future. Nobody (I guess) needs this article!
Mustafa Demirhan http://www.macroangel.com Sonork ID 100.9935:zoltrix
They say I'm lazy but it takes all my time
|
|
|
|
 |
|
 |
Whilst the article may not be up to much, the source may be of use to somebody.
Maybe it's time to look at the Code Snippets idea again
Michael
The avalanche has started, it's too late for the pebbles to vote.
|
|
|
|
 |
|
 |
I agree. I suspect many people are upset that there are so many smaller code submissions amongst the larger articles, so the idea of Code Snippets sounds very good indeed. This article would fit nicely in such a section, and would not be receiving all the nasty comments it's getting. It would benefit CodeProject, the submitters of articles large and small, and the readers.
Code Snippets -> Let those in favour send Chris a nice email in support of it (or whatever solution they prefer). I know many already have, but an equitable solution must be found, so let's not give up.
|
|
|
|
 |
|
|
 |
|
 |
Harsh words! The code isn't not formatting my hard drive and he's not claiming his code will revolutionize the world or anything. It's just a simple wrapper which he apparently wanted to share with others.
So what if his code is less useful, you still shouldn't post messages like that. Do you have any idea how much those words can hurt? He didn't deserve those words.
My 2 cents.
-- "It is amazing how f-ing crazy I really am."
|
|
|
|
 |
|
 |
Jörgen Sigvardsson wrote: So what if his code is less useful
You haven't looked the code. Beyond the point of being tiny and strictly useless, it's badly written.
As a side note, please find below my registry wrapper,
struct CMyCoolRegistry { HKEY OpenRegistryKey(HKEY hKey,LPCTSTR lpSubKey,PHKEY phkResult) { return ::RegOpenKey(hKey,lpSubKey, phkresult); } long RegCloseKey(HKEY hKey) { return ::RegCloseKey(hKey); } };
Is that powerful enough, or do you want to add more cool features?
|
|
|
|
 |
|
 |
If I look at your code I would judge this bad (excuse me imho "crap")
Your code: 1. class instead of struct 2. there is No internal functionality 3. use of members 4. checking of results 5. what is wrapped? (Nothing)
The code of the article: (see upside) 1. ok 2. ok 3. no 4. no 5. ok (little) 50%
That means that your code got 0 points out of 5, the articles code 2,5 of 5 point. You got to learn a lot maybe not only programming...
(If you were here, I would at first ask you whether you can stand the truth)
Try this @ home. (B&B)
|
|
|
|
 |
|
 |
KarstenK wrote: 1. class instead of struct
Why? What's the difference betweenclass C { public: ... };andstruct S { ... };? Other than the fact that the latter is shorter I fail to see a difference.
Although I wouldn't rate this article as crap the provided code has some poor spots -- hardcoding drive C:\ into code that is used by clients is simply a no-no. What happens if it runs on a machine that doesn't have a drive C:\ ? Using GetWindowsDirectory would certainly be wise here.
.f
p.s.: A #pragma warning( disable : nnn ) in a header file is ok, as long as the previous compiler state is restored at the end of the respective header. Disabling warning 4089 is severe as it is, invalidating most of C++'s strong typing. Failing to restore the warning state, especially in this case, is pretty much as bad as it gets. If the original author feels the need that (s)he can't leave this warning untouched (aren't there static_cast<...> and reinterpret_cast<...> in C++?) (s)he should at least embrace the modified warning settings in #pragma warning( push ) and #pragma warning( pop ) compiler directives.
Other bad things: strings being cast to LPCTSTR, yet failing to make sure that it also works with UNICODE defined, by applying a simple _T( "..." ) macro.
All class members could be made static and both c'tor and d'tor hidden by making them private to disable instantiating this class -- after all, there is nothing to be gained by creating an instance to be able to call it's members.
The bottom line: This wrapper class isn't poor because it doesn't do much, but simply for the reason of being crafted in the most sloppy way possible. So I would have to agree with .S.Rod. who started this thread, although I would have like to have seen this stated in a more constructive criticism.
|
|
|
|
 |
|
 |
There are only slight diffs between classes and structs, or I don't know them all. (One is private access in classes, which enforces capsulation)
Try this @ home. (B&B)
|
|
|
|
 |
|
 |
That's the only difference: the default access modifier is public in struct's and private in class's. But what is so cool about private members in a monostate? Hence a struct is exactly what you need in this situation. It is simply a namespace that cannot be globally resolved by a using namespace directive. Anyway, there is no "a class is better than a struct", at least not in my reality.
.f
|
|
|
|
 |
|
 |
I did look at the code, and yes I did see it was a very thin layer ontop of SHGetFileInfo(). However, it can simplify client code considerably. And he also mentions this - ... It's a very simple class, but I think it can be usefull. You will not have to worry anymore about setting flags ... He didn't just paste the code into a big <pre> block. He did state the simplicity of the class, and documented its API. What more do you ask of him for this particular code?
Just look at CUseShGetFileInfo::GetFileType(). It compresses code quite a lot! If scrapping boiler plate code isn't useful, then I guess I'm a really lousy programmer, because that's what I do as often as possible.
If you have a problem with the article, rate it and explain why you dislike it. In any case, you have no right to insult him. Even less so if you're not even explaing why you are insulting him!
-- "It is amazing how f-ing crazy I really am."
|
|
|
|
 |