Welcome to mirror list, hosted at ThFree Co, Russian Federation.

osspecific.h « windirstat - github.com/windirstat/windirstat.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0d891708bfe490822ac452c9838902d5c10dbe5c (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// osspecific.h - Declaration of CVolumeApi, CRecycleBinApi, CPsapi,
//                CGetDiskFreeSpaceApi, CGetCompressedFileSizeApi
//
// WinDirStat - Directory Statistics
// Copyright (C) 2003-2005 Bernhard Seifert
// Copyright (C) 2004-2017 WinDirStat Team (windirstat.net)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//

#ifndef __WDS_OSSPECIFIC_H__
#define __WDS_OSSPECIFIC_H__
#pragma once
#include <Windows.h>
#include <ShellAPI.h>

BOOL FileIconInit(__in  BOOL fRestoreCache);
CString GetCurrentDesktopName();
CString GetCurrentWinstaName();

class CAbstractionLayer
{
    CAbstractionLayer()
    {
    }
};

const LPCTSTR nameKernel32 = _T("kernel32.dll");
const LPCTSTR nameShell32 = _T("shell32.dll");
const LPCTSTR namePsApi = _T("psapi.dll");

///////////////////////////////////////////////////////////////////////////////
///  CDllModule
///  Encapsulates the module handle for a DLL given the DLL name in the ctor
///
///
///  @remarks Should be preferably used as a static instance.
///////////////////////////////////////////////////////////////////////////////
class CDllModule
{
public:
    ///////////////////////////////////////////////////////////////////////////////
    ///  inline public constructor  CDllModule
    ///  Ctor for the CDllModule wrapper class
    ///
    ///  @param [in]       DllName LPCTSTR    Name of the DLL of which we want the handle
    ///
    ///  This function doesn't return a value
    ///////////////////////////////////////////////////////////////////////////////
    CDllModule(LPCTSTR DllName)
    {
        m_hDll = LoadLibrary(DllName);
    }

    ///////////////////////////////////////////////////////////////////////////////
    ///  inline public destructor  ~CDllModule
    ///  Dtor for the CDllModule wrapper class
    ///
    ///  This function doesn't return a value
    ///////////////////////////////////////////////////////////////////////////////
    ~CDllModule()
    {
        if(m_hDll)
        {
            FreeLibrary(m_hDll);
        }
    }

    ///////////////////////////////////////////////////////////////////////////////
    ///  inline public  Handle
    ///  Returns the module handle value of this class instance
    ///
    ///  @return HMODULE Returns the module handle or NULL if there is no valid handle
    ///
    ///  @remarks The caller is responsible to verify the returned handle!
    ///////////////////////////////////////////////////////////////////////////////
    HMODULE Handle()
    {
        return m_hDll;
    }

private:
    ///////////////////////////////////////////////////////////////////////////////
    ///  HMODULE m_hDll
    ///  The private member variable which holds the module handle
    ///
    ///  @remarks This is initialized directly inside the ctor!
    ///////////////////////////////////////////////////////////////////////////////
    HMODULE m_hDll;
};

extern CDllModule dllKernel32;
extern CDllModule dllShell32;
extern CDllModule dllPsApi;

///////////////////////////////////////////////////////////////////////////////
///  CDynamicApi
///  Template class to implement dynamic linking to functions
///
///
///  @remarks Preferably used as a class member variable and initialized in the
///           initializer list.
///////////////////////////////////////////////////////////////////////////////
template <class FctType> class CDynamicApi
{
public:
    ///////////////////////////////////////////////////////////////////////////////
    ///  inline public constructor  CDynamicApi
    ///  Ctor of the dynamic linking template class
    ///
    ///  @param [in]       hDll HMODULE    Module handle to the DLL implementing the wrapped function
    ///  @param [in]       pszFctName LPCSTR    Name of the function (ANSI)
    ///
    ///  This function doesn't return a value
    ///////////////////////////////////////////////////////////////////////////////
    CDynamicApi(HMODULE hDll, LPCSTR pszFctName)
        : pfnFct(0)
    {
        if(hDll)
        {
            pfnFct = reinterpret_cast<FctType>(GetProcAddress(hDll, pszFctName));
        }
    }

    ///////////////////////////////////////////////////////////////////////////////
    ///  inline public  IsSupported
    ///  Used to check whether the wrapped function is supported (found)
    ///
    ///  @return bool true if the function can be called, false otherwise
    ///////////////////////////////////////////////////////////////////////////////
    bool IsSupported()
    {
        return (pfnFct != NULL);
    }

public:
    FctType pfnFct;
};

#endif // __WDS_OSSPECIFIC_H__