📄 shellextobj.cpp
字号:
// ShellExtObj.cpp : Implementation of CShellExtObj
#include "stdafx.h"
#include "ShellExt_TxtInfo.h"
#include "ShellExtObj.h"
/////////////////////////////////////////////////////////////////////////////
// CShellExtObj
// Load the file's name selected
HRESULT CShellExtObj::Load ( LPCOLESTR wszFilename, DWORD dwMode )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); // init MFC
// Let CString convert the filename to ANSI if necessary.
m_sFilename = wszFilename;
return S_OK;
}
HRESULT CShellExtObj::GetInfoTip (DWORD dwFlags,LPWSTR* ppwszTip )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); // init MFC
LPMALLOC pMalloc;
CStdioFile file;
DWORD dwFileSize;
CString sFirstLine;
BOOL bReadLine;
CString sTooltip;
USES_CONVERSION;
if ( !file.Open ( m_sFilename , CFile::modeRead | CFile::shareDenyWrite ))
return E_FAIL;
if ( FAILED( SHGetMalloc ( &pMalloc )))
return E_FAIL;
// Get the size of the file.
dwFileSize = file.GetLength();
// Read in the first line from the file.
bReadLine = file.ReadString ( sFirstLine );
sTooltip.Format ( _T("File size: %lu"), dwFileSize );
if ( bReadLine )
{
sTooltip += _T("\n");
sTooltip += sFirstLine;
}
*ppwszTip = (LPWSTR) pMalloc->Alloc ( (1 + lstrlen(sTooltip)) * sizeof(wchar_t) );
if ( NULL == *ppwszTip )
{
pMalloc->Release();
return E_OUTOFMEMORY;
}
// Use the Unicode string copy function to put the tooltip text in the buffer.
wcscpy ( *ppwszTip, T2COLE((LPCTSTR) sTooltip) );
pMalloc->Release();
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -