Menu

[r122]: / trunk / src / SysImageList.cpp  Maximize  Restore  History

Download this file

103 lines (78 with data), 1.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#include "stdafx.h"
#include "SysImageList.h"
#include "shellapi.h"
#pragma comment(lib, "shell32.lib")
// Singleton constructor and destructor (private)
CSysImageList * CSysImageList::instance = 0;
CSysImageList::CSysImageList()
{
SHFILEINFO ssfi;
TCHAR windir[MAX_PATH];
GetWindowsDirectory(windir, MAX_PATH); // MAX_PATH ok.
m_hSystemImageList =
(HIMAGELIST)SHGetFileInfo(
windir,
0,
&ssfi, sizeof ssfi,
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
}
CSysImageList::~CSysImageList()
{
}
// Singleton specific operations
CSysImageList& CSysImageList::GetInstance()
{
if (instance == 0)
instance = new CSysImageList;
return *instance;
}
void CSysImageList::Cleanup()
{
delete instance;
instance = 0;
}
// Operations
int CSysImageList::GetDirIconIndex() const
{
SHFILEINFO sfi;
ZeroMemory(&sfi, sizeof sfi);
SHGetFileInfo(
_T("Doesn't matter"),
FILE_ATTRIBUTE_DIRECTORY,
&sfi, sizeof sfi,
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
return sfi.iIcon;
}
int CSysImageList::GetDirOpenIconIndex() const
{
SHFILEINFO sfi;
ZeroMemory(&sfi, sizeof sfi);
SHGetFileInfo(
_T("Doesn't matter"),
FILE_ATTRIBUTE_DIRECTORY,
&sfi, sizeof sfi,
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES | SHGFI_OPENICON);
return sfi.iIcon;
}
int CSysImageList::GetDefaultIconIndex() const
{
SHFILEINFO sfi;
ZeroMemory(&sfi, sizeof sfi);
SHGetFileInfo(
_T(""),
FILE_ATTRIBUTE_NORMAL,
&sfi, sizeof sfi,
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
return sfi.iIcon;
}
int CSysImageList::GetFileIconIndex(const wstring& file) const
{
SHFILEINFO sfi;
ZeroMemory(&sfi, sizeof sfi);
SHGetFileInfo(
file.c_str(),
FILE_ATTRIBUTE_NORMAL,
&sfi, sizeof sfi,
SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
return sfi.iIcon;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.