当前位置: 首页>>代码示例>>C++>>正文


C++ SHGetFileInfo函数代码示例

本文整理汇总了C++中SHGetFileInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ SHGetFileInfo函数的具体用法?C++ SHGetFileInfo怎么用?C++ SHGetFileInfo使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SHGetFileInfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memcpy

// 接受文件,然后等待用户确认是否接收 [保存] [另存] [拒收]
void CXRecvDlg::AddFile(LPXFILEINFO pFileInfo)
{
	memcpy((char*)&m_xFileInfo, pFileInfo, sizeof(XFILEINFO));

//	CString str;
//	str.Format("%d", m_xFileInfo.dwPort);
//	AfxMessageBox(str);
	SetDlgItemText(IDC_FILE_NAME, m_xFileInfo.szShortName);

	SHFILEINFO shfi;
	SHGetFileInfo(m_xFileInfo.szFullName,FILE_ATTRIBUTE_NORMAL,&shfi,
		sizeof(shfi),SHGFI_ICON|SHGFI_USEFILEATTRIBUTES);

	if (NULL != shfi.hIcon)
	{
		GetDlgItem(IDC_STATIC_ICON)->SendMessage(STM_SETIMAGE, IMAGE_ICON, (LPARAM)shfi.hIcon);
	}
	else
	{
		MessageBox("Could not retrieve the file icon.");
	}
}
开发者ID:Crawping,项目名称:XEIM,代码行数:23,代码来源:XRecvDlg.cpp

示例2: SHGetFileInfo

//=============================================================================
// Function: Create
// Purpose: Finds, logs in, etc. to the request volume.
//=============================================================================
bool wxFSVolumeBase::Create(const wxString& name)
{
    // assume fail.
    m_isOk = false;

    // supplied.
    m_volName = name;

    // Display name.
    SHFILEINFO fi;
    long rc = SHGetFileInfo(m_volName.t_str(), 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME);
    if (!rc)
    {
        wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str());
        return false;
    }
    m_dispName = fi.szDisplayName;

    // all tests passed.
    m_isOk = true;
    return true;
} // Create
开发者ID:CustomCardsOnline,项目名称:wxWidgets,代码行数:26,代码来源:volume.cpp

示例3: SendMessage

void CDirectoryTreeCtrl::Init(bool bAllowCDROM /*= true*/)
{
#ifdef _UNICODE
//	Win9x: Explicitly set to Unicode to receive Unicode notifications.
	SendMessage(CCM_SETUNICODEFORMAT, TRUE);
#endif

	DeleteAllItems();

	SHFILEINFO shFinfo;
	HIMAGELIST hImgList;
	CImageList imageList;

//	Get the system image list using a "path" which is available on all systems. [patch by bluecow]
	hImgList = (HIMAGELIST)SHGetFileInfo(_T("."), FILE_ATTRIBUTE_DIRECTORY, &shFinfo, sizeof(shFinfo), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
	imageList.Attach(hImgList);
	SetImageList(&imageList, TVSIL_NORMAL);
//	Don't destroy the system's image list
	imageList.Detach();

	TCHAR drivebuffer[128], cDrv, *pos = drivebuffer;

	::GetLogicalDriveStrings(ARRSIZE(drivebuffer), drivebuffer); // e.g. "a:\ c:\ d:\"
	while(*pos != _T('\0'))
	{
		UINT	dwDrvType = ::GetDriveType(pos);

	//	Skip floppy drives (check letter as some USB drives can also be removable) and in some cases CD/DVD
		if ( ((dwDrvType != DRIVE_REMOVABLE) || (((cDrv = CHR2UP(*pos)) != _T('A')) && (cDrv != _T('B')))) &&
			(bAllowCDROM || (dwDrvType != DRIVE_CDROM)) )
		{
			pos[2] = _T('\0');
			AddChildItem(NULL, pos); // e.g. ("c:")
		}
	//	Point to the next drive (4 chars interval)
		pos += 4;
	}
}
开发者ID:rusingineer,项目名称:EmulePlus,代码行数:38,代码来源:DirectoryTreeCtrl.cpp

示例4: QTFrame_GetDisplayName

void QTFrame_GetDisplayName (char *thePathName, char *theDispName)
{
	SHFILEINFO			myFileInfo;
	DWORD				myResult;
	
	myResult = SHGetFileInfo(thePathName, (DWORD)0, &myFileInfo, sizeof(myFileInfo), SHGFI_DISPLAYNAME);
	if (myResult != 0) {
		// SHGetFileInfo successful
		strcpy(theDispName, myFileInfo.szDisplayName);
	} else {
		// SHGetFileInfo not successful, so find the basename ourselves
		short	myLength = 0;
		short	myIndex;

		// get the length of the pathname
		myLength = strlen(thePathName);
		
		// find the position of the rightmost path separator in thePathName
		if (strchr(thePathName, kWinFilePathSeparator) != NULL) {
	
			myIndex = myLength - 1;
			while (thePathName[myIndex] != kWinFilePathSeparator)
				myIndex--;
				
			// calculate the length of the basename
			myLength = myLength - myIndex - 1;
	
		} else {
			// there is no rightmost path separator in thePathName;
			// set myIndex so that myIndex + 1 == 0, for the call to BlockMove below
			myIndex = -1;
		}
		
		// copy into theDispName the substring of thePathName from myIndex + 1 to the end
		BlockMove(&thePathName[myIndex + 1], theDispName, myLength);
		theDispName[myLength] = '\0';
	}
}
开发者ID:fruitsamples,项目名称:qtbigscreen,代码行数:38,代码来源:WinFramework.c

示例5: getFileExt

/**
 *\fn           int getFileExtId(const char *filename)
 *\brief        得到文件扩展名ID
 *\param[in]    const char * filename 文件名
 *\return       int 扩展名ID
 */
int CBrowseWnd::getFileExtId(const char *filename)
{
    int id = 0;
    const char *ext = getFileExt(filename);

    mapStrInt::iterator iter = mapExtImage_.find(ext);

    if (iter == mapExtImage_.end())
    {
        SHFILEINFO info = {0};
        SHGetFileInfo(filename, 0, &info, sizeof(info), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES );

        id = ImageList_AddIcon(hImageList_, info.hIcon);

        mapExtImage_[ext] = id;
    }
    else
    {
        id = iter->second;
    }

    return id;
}
开发者ID:xt9852,项目名称:TestSet,代码行数:29,代码来源:BrowseWnd.cpp

示例6: ZeroMemory

CSystemImageList::CSystemImageList()
{
  //We need to implement reference counting to 
  //overcome an MFC limitation whereby you cannot
  //have two CImageLists attached to the one underlyinh
  //HIMAGELIST. If this was not done then you would get 
  //an ASSERT in MFC if you had two or more CTreeFileCtrl's
  //in your program at the same time
  if (m_nRefCount == 0)
  {
    //Attach to the system image list
    SHFILEINFO sfi;
	ZeroMemory(&sfi, sizeof(SHFILEINFO));
    HIMAGELIST hSystemImageList = (HIMAGELIST) SHGetFileInfo(_T("C:\\"), 0, &sfi, sizeof(SHFILEINFO),
                                                             SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
    VERIFY(m_ImageList.Attach(hSystemImageList));
	if (sfi.hIcon)
	  DestroyIcon(sfi.hIcon);
  }  

  //Increment the reference count
  m_nRefCount++;
}
开发者ID:mikemakuch,项目名称:muzikbrowzer,代码行数:23,代码来源:FileAndFolder.cpp

示例7: SHGetFileInfo

void Explorerplusplus::SetAddressBarText(LPITEMIDLIST pidl, const TCHAR *szDisplayText)
{
	SHFILEINFO shfi;
	DWORD_PTR dwRet = SHGetFileInfo(reinterpret_cast<LPTSTR>(pidl), NULL, &shfi,
		NULL, SHGFI_PIDL | SHGFI_SYSICONINDEX);

	if(dwRet == 0)
	{
		return;
	}

	SendMessage(m_hAddressBar, CB_RESETCONTENT, 0, 0);

	COMBOBOXEXITEM cbItem;
	cbItem.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_INDENT | CBEIF_SELECTEDIMAGE;
	cbItem.iItem = -1;
	cbItem.iImage = shfi.iIcon;
	cbItem.iSelectedImage = shfi.iIcon;
	cbItem.iIndent = 1;
	cbItem.iOverlay = 1;
	cbItem.pszText = const_cast<LPTSTR>(szDisplayText);
	SendMessage(m_hAddressBar, CBEM_SETITEM, 0, reinterpret_cast<LPARAM>(&cbItem));
}
开发者ID:defhook,项目名称:explorerplusplus,代码行数:23,代码来源:AddressBarHandler.cpp

示例8: ADD_LOG

VOID CTabPageProgram::AddWatchProgramList(LPCTSTR lpszPath,
	LPCTSTR lpszID, LPCTSTR lpszName,
	int nCounts, int nWaitTime,
	BOOL bRecovery, LPCTSTR lpszEvent) {

	ADD_LOG();
	CString temp;

	if (!IsWindow(m_hWnd)) return;
	
	SHFILEINFO sfi;
	HIMAGELIST imagelist;
	imagelist = (HIMAGELIST)SHGetFileInfo(lpszPath, FILE_ATTRIBUTE_NORMAL, &sfi,
		sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME);
	m_ImageList.Add(sfi.hIcon);
	int n = m_ImageList.GetImageCount();

	INT ncount = m_lt_ShowProgram.GetItemCount();
	
	ncount = m_lt_ShowProgram.InsertItem(ncount, _T(""), -1);
	temp.Empty(), temp.Format(_T("%d"), ++s_nNumber);
	m_lt_ShowProgram.SetItemText(ncount, 1, temp);
	m_lt_ShowProgram.SetItemText(ncount, 2, lpszID);
	m_lt_ShowProgram.SetItemText(ncount, 3, lpszName);
	temp.Empty(), temp.Format(_T("%d"), nCounts);
	m_lt_ShowProgram.SetItemText(ncount, 4, temp);
	temp.Empty(), temp.Format(_T("%d"), nWaitTime);
	m_lt_ShowProgram.SetItemText(ncount, 5, temp);
	m_lt_ShowProgram.SetItem(ncount, 6, LVIF_IMAGE, NULL, ncount, NULL, NULL, 0, 0);
	m_lt_ShowProgram.SetItemText(ncount, 7, lpszEvent);

	if (bRecovery) {
		ListView_SetItemState(m_lt_ShowProgram.m_hWnd, ncount, (UINT(TRUE + 1)) << 12, LVIS_STATEIMAGEMASK);
	}
	else ListView_SetItemState(m_lt_ShowProgram.m_hWnd, ncount, (UINT(FALSE + 1)) << 12, LVIS_STATEIMAGEMASK);

}
开发者ID:XueCat,项目名称:sobey,代码行数:37,代码来源:TabPageProgram.cpp

示例9: Init_Browser

//初始化浏览器控件(nID为资源文件中树型控件的id)
BOOL Init_Browser(HWND hWnd,UINT nID)
{
	HIMAGELIST hImageList;
   LPSHELLFOLDER lpsf = 0 ;
   SHFILEINFO    sfi;
	HRESULT hr ;
	BOOL bOK;

	memset(szFoldername,0,MAX_PATH);
   hTreeWnd=GetDlgItem(hWnd,nID);

   hImageList = (HIMAGELIST)SHGetFileInfo((LPCSTR)"C:\\",
                                           0,
                                           &sfi,
                                           sizeof(SHFILEINFO),
                                           SHGFI_SYSICONINDEX | SHGFI_SMALLICON) ;

  	if(hImageList)
   	TreeView_SetImageList(hTreeWnd,hImageList,0);

	hr=SHGetDesktopFolder(&lpsf) ;

	if( SUCCEEDED(hr))
	{
	   TreeView_DeleteAllItems(hTreeWnd);
	   FillTreeView(hTreeWnd,lpsf,NULL,TVI_ROOT) ;
      ExpandTree();
      TreeView_SelectItem(hTreeWnd,TreeView_GetRoot(hTreeWnd));//,TVGN_FIRSTVISIBLE);
      bOK = TRUE;
	}
   else
   	bOK = FALSE;

	if(lpsf)
		lpsf->Release();
	return bOK;
}
开发者ID:tianjigezhu,项目名称:UI-Library,代码行数:38,代码来源:browser.cpp

示例10: SHGetFileInfo

void CDownloadsView::AddItem(CString fileName, DWORD size, DWORD nReceiveSize, CString strStatus, CString serverName, UINT nNum)
{
	CMainFrame *pMain = ((CMainFrame *)AfxGetMainWnd());

	SHFILEINFO sfi;
    SHGetFileInfo(fileName, 0, &sfi, sizeof(SHFILEINFO), SHGFI_USEFILEATTRIBUTES | SHGFI_ICON );
	int img = sfi.iIcon;

	LV_ITEM a;
	a.iItem = m_listDownloads.GetItemCount();	// 삽입 위치
	a.mask = LVIF_TEXT | LVIF_IMAGE  | LVIF_STATE;	// 실직적으로 표현될값
	a.iSubItem = 0;	// 열인덱스
	a.iImage = img;	// 이미지 인덱스
	a.stateMask = LVIS_STATEIMAGEMASK;	// 상태변화를 Mask 처리
	a.state = INDEXTOSTATEIMAGEMASK(1);	// 유효한 상태 비트
	fileName.Format("%s", fileName);
	a.pszText = (LPSTR)(LPCTSTR) fileName;	// 문자열 
	CString temp;
	m_listDownloads.InsertItem(&a);	
	temp.Format("%s KB", pMain->ChangeComma(size));
	m_listDownloads.SetItemText(a.iItem, 1, temp);
	temp.Format("%s KB", pMain->ChangeComma(nReceiveSize));
	m_listDownloads.SetItemText(a.iItem, 2, temp);

	char szReceiveSize[256];
	float total = (float)size;
	float recv = (float)nReceiveSize;
	int pu = (int)ceil((recv / total) * 100);
	sprintf(szReceiveSize, "[ %d%% ]", pu);		
	m_listDownloads.SetItemText(a.iItem, 3, szReceiveSize);

	m_listDownloads.SetItemText(a.iItem, 4, strStatus);
	m_listDownloads.SetItemText(a.iItem, 5, serverName);
	temp.Format("%d", nNum);
	m_listDownloads.SetItemText(a.iItem, 6, temp);	// 의미는 없지만 조금더 편하게 하기위해번호를 부여(실제다운받는것고연동을위해)
}
开发者ID:hoonio,项目名称:distributed-system,代码行数:36,代码来源:DownloadsView.cpp

示例11: ModifyShortCutComo

void CDuiAddFrame::SetInfo(int Type, LPWSTR lpFilePath, CDuiFrameWnd* pWnd)
{
	m_pImage = static_cast<CButtonUI*>( m_PaintManager.FindControl(_T("DUI_BTN_IMAGE")) );
	m_pPath = static_cast<CTextUI*>( m_PaintManager.FindControl(_T("DUI_TXT_PATH")) );
	m_pType = static_cast<CComboUI*>( m_PaintManager.FindControl(_T("DUI_COMB_TYPE")) );
	m_pShortCut = static_cast<CComboUI*>( m_PaintManager.FindControl(_T("DUI_TXT_SHORTCUT")));

	if(m_pPath){
		m_pPath->SetText(lpFilePath);
	}

	m_Type = Type;
	m_pWnd = pWnd;


	m_pType->SelectItem(m_Type - 1);

	ModifyShortCutComo();

	HBITMAP hBitmap;

	// 获取图片
	if(m_pImageList != NULL){
		SHFILEINFOW sfi = {0};
		SHGetFileInfo(lpFilePath, -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX);

		HICON hIcon;
		HRESULT hResult = ((IImageList*)m_pImageList)->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hIcon);
		if(hResult == S_OK){
			hBitmap = ConvertIconToBitmap(hIcon);
			if(SaveBitmapToFile(hBitmap, m_ImagePath.GetData())){
				m_pImage->SetBkImage(m_ImagePath);
			}
		}
	}
}
开发者ID:AlwaysKing,项目名称:DesktopSprite,代码行数:36,代码来源:AddFrame.cpp

示例12: GetFileIcon

HICON GetFileIcon(LPCWSTR pszFilePath)
{
	SHFILEINFOW sfi = {0};
	SHGetFileInfo(pszFilePath, -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX);

	// Retrieve the system image list.
	// To get the 48x48 icons, use SHIL_EXTRALARGE
	// To get the 256x256 icons (Vista only), use SHIL_JUMBO
	HIMAGELIST* imageList;
	HRESULT hResult = SHGetImageList(SHIL_EXTRALARGE, IID_IImageList, (void**)&imageList);
	HICON hIcon;
	if (hResult == S_OK) {
		// Get the icon we need from the list. Note that the HIMAGELIST we retrieved
		// earlier needs to be casted to the IImageList interface before use.
		
		hResult = ((IImageList*)imageList)->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hIcon);

		if (hResult == S_OK) {

		}
	}

	return hIcon;
}
开发者ID:gaozan198912,项目名称:myproject,代码行数:24,代码来源:DeskTopDlg.cpp

示例13: PyMFC_PROLOGUE

	static PyObject *getSysIconIndex(TypeInstance *obj, PyObject *args, PyObject *kwds) {
		PyMFC_PROLOGUE("PyMFCPIDL::getSysIconIndex");
		
		BOOL smallIcon=FALSE;
		static char *kwlist[] = {"small", NULL};

		if (!PyArg_ParseTupleAndKeywords(args, kwds, 
				"|i", kwlist, &smallIcon))
			return NULL;

		UINT f = SHGFI_PIDL | SHGFI_SYSICONINDEX;
		if (smallIcon) {
			f |= SHGFI_SMALLICON;
		}

		SHFILEINFO fi;
		if (NULL ==SHGetFileInfo((const TCHAR *)obj->pidl, 0, &fi, sizeof(fi), f)) {
			throw PyMFC_WIN32ERR();
		}
		
		return PyDTInt(fi.iIcon).detach();

		PyMFC_EPILOGUE(NULL);
	}
开发者ID:atsuoishimoto,项目名称:pymfc,代码行数:24,代码来源:pymfc_shlobj.cpp

示例14: wceex_wchdir

int wceex_wchdir( const wchar_t *dirname )
{
    if( !dirname || *dirname == 0 )
    {
        errno = ENOENT;
        return -1;
    }
    else
    {
        SHFILEINFO fi;
        if( !SHGetFileInfo( dirname, 0, &fi, sizeof(fi), SHGFI_ATTRIBUTES ) )
        {
            errno = ENOENT;
            return -1;
        }
        if( !(fi.dwAttributes & SFGAO_FOLDER) )
        {
            errno = ENOENT;
            return -1;
        }
        wcscpy( Cwd, dirname );
        return 0;
    }
}
开发者ID:kmribti,项目名称:sandbox,代码行数:24,代码来源:wce_directorymanagement.c

示例15: GetDefaultIcon

int GetDefaultIcon(DefaultIconType defaultIconType)
{
	SHFILEINFO shfi;
	DWORD dwFileAttributes;

	switch(defaultIconType)
	{
		case DEFAULT_ICON_FOLDER:
			dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_NORMAL;
			break;

		case DEFAULT_ICON_FILE:
		default:
			dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
			break;
	}

	/* Under unicode, the filename argument cannot be NULL,
	as it is not a valid unicode character. */
	SHGetFileInfo(_T("dummy"),dwFileAttributes,&shfi,
	sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);

	return shfi.iIcon;
}
开发者ID:hollylee,项目名称:explorerplusplus,代码行数:24,代码来源:ShellHelper.cpp


注:本文中的SHGetFileInfo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。