-
Notifications
You must be signed in to change notification settings - Fork 0
/
FilesHelp.h
102 lines (83 loc) · 2.74 KB
/
FilesHelp.h
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
#pragma once
#include "stdafx.h"
#include <vector>
using namespace std;
class CFileHelp
{
public:
CFileHelp(void);
~CFileHelp(void);
public:
//打开对话框 lpstrFilter:过滤字符串 hwndOwner:父窗口 fileNames:完整文件路径
static BOOL OpenFile(LPCWSTR lpstrFilter, HWND hwndOwner, vector<SStringT> &fileNames, bool IsMulti = true);
//把一个绝对路径拆分成,文件名、扩展名
static void SplitPathFileName(SStringT fileName, SStringT &szName, SStringT &szExt);
// 浏览文件夹 path:路径 hwndOwner : 父窗口 tile : 窗口标题
static BOOL BrowseDir(SStringT &path, HWND hwndOwner, SStringT title);
// 检查文件后缀名 pstrPath:文件路径 pstrExtFilter:过滤列表
static bool FindFileExt(LPCTSTR pstrPath, LPCTSTR pstrExtFilter);
//递归遍历当前目录内文件文件
static void EnumerateFiles(vector<SStringT> &vctString, LPCTSTR p_strExtFilter);
//得到文件的大小
static DWORD GetFileSize(LPCTSTR fileName);
//文件大小转换为字符换: xx.xxM
static LPCTSTR FileSizeToString(DWORD dwSize);
//文件总时间04:00
static SStringT TimeToToleString(int time);
//检查文件是否存在
static BOOL CheckFileExist(SStringT pathFileName);
};
class CTestDropTarget :public IDropTarget
{
public:
CTestDropTarget()
{
nRef = 0;
}
virtual ~CTestDropTarget() {}
//////////////////////////////////////////////////////////////////////////
// IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject)
{
HRESULT hr = S_FALSE;
if (riid == __uuidof(IUnknown))
*ppvObject = (IUnknown*) this, hr = S_OK;
else if (riid == __uuidof(IDropTarget))
*ppvObject = (IDropTarget*)this, hr = S_OK;
if (SUCCEEDED(hr)) AddRef();
return hr;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void) { return ++nRef; }
virtual ULONG STDMETHODCALLTYPE Release(void) {
ULONG uRet = --nRef;
if (uRet == 0) delete this;
return uRet;
}
//////////////////////////////////////////////////////////////////////////
// IDropTarget
virtual HRESULT STDMETHODCALLTYPE DragEnter(
/* [unique][in] */ __RPC__in_opt IDataObject *pDataObj,
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ __RPC__inout DWORD *pdwEffect)
{
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE DragOver(
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ __RPC__inout DWORD *pdwEffect)
{
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE DragLeave(void)
{
return S_OK;
}
protected:
int nRef;
};