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


C++ IShellLink::GetIconLocation方法代码示例

本文整理汇总了C++中IShellLink::GetIconLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellLink::GetIconLocation方法的具体用法?C++ IShellLink::GetIconLocation怎么用?C++ IShellLink::GetIconLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IShellLink的用法示例。


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

示例1: GetI

// @pymethod str|PyIShellLink|GetIconLocation|Retrieves the location (path and index) of the icon for a shell link object.
PyObject *PyIShellLink::GetIconLocation(PyObject *self, PyObject *args)
{
	IShellLink *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	// @pyparm int|cchMaxPath|_MAX_PATH|Number of characters to allocate for the result string.
	int cchIconPath = _MAX_PATH;
	if ( !PyArg_ParseTuple(args, "|i:GetIconLocation", &cchIconPath) )
		return NULL;
	TCHAR *pszIconPath = (TCHAR *)malloc(cchIconPath * sizeof(TCHAR) );
	if (pszIconPath==NULL) {
		PyErr_SetString(PyExc_MemoryError, "allocating string buffer");
		return NULL;
	}
	HRESULT hr;
	int iIcon;
	PY_INTERFACE_PRECALL;
	hr = pISL->GetIconLocation( pszIconPath, cchIconPath, &iIcon );
	PY_INTERFACE_POSTCALL;

	PyObject *ret;
	if ( FAILED(hr) )
		ret = OleSetOleError(hr);
	else
		ret = Py_BuildValue("Ni", PyWinObject_FromTCHAR(pszIconPath), iIcon);
	free(pszIconPath);
	return ret;
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:29,代码来源:PyIShellLink.cpp

示例2: GetLinkInfo

bool ShellIO::GetLinkInfo(CString fileName, LinkInfo *linkInfo, int flags)
{
	IShellLink *psl;
	IPersistFile *ppf;
	HRESULT hRes;
	bool ret = false;

	hRes = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);
    if(SUCCEEDED(hRes))
    {
        hRes = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
        if(SUCCEEDED(hRes))
        {
			hRes = ppf->Load(fileName.GetBuffer(), NULL);
			if(SUCCEEDED(hRes))
			{
				wchar_t buf[1000];

				if((flags & LI_DESCRIPTION) == LI_DESCRIPTION)
				{
					memset(buf, 0, sizeof(buf));
					hRes = psl->GetDescription(buf, 1000);
					if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
					{
						linkInfo->description = buf;
						ret = true;
					}
					else
					{
						linkInfo->description.Empty();
					}
				}

				if((flags & LI_PATH) == LI_PATH)
				{
					LPITEMIDLIST pidl;
					hRes = psl->GetIDList(&pidl);
					if(SUCCEEDED(hRes) && pidl)
					{
						linkInfo->path = PIDLToString(pidl, NULL, SHGDN_FORPARSING);
						ILFree(pidl);
						ret = !linkInfo->path.IsEmpty();
					}
					else
					{
						linkInfo->path.Empty();
					}
				}

				if((flags & LI_ARGUMENTS) == LI_ARGUMENTS)
				{
					memset(buf, 0, sizeof(buf));
					hRes = psl->GetArguments(buf, 1000);
					if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
					{
						linkInfo->arguments = buf;
						ret = true;
					}
					else
					{
						linkInfo->arguments.Empty();
					}
				}

				if((flags & LI_WORKDIRECTORY) == LI_WORKDIRECTORY)
				{
					memset(buf, 0, sizeof(buf));
					hRes = psl->GetWorkingDirectory(buf, 1000);
					if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
					{
						linkInfo->workDirectory = buf;
						ret = true;
					}
					else
					{
						linkInfo->workDirectory.Empty();
					}
				}

				if((flags & LI_ICONLOCATION) == LI_ICONLOCATION)
				{
					int iIcon;
					memset(buf, 0, sizeof(buf));
					hRes = psl->GetIconLocation(buf, 1000, &iIcon);
					if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
					{
						linkInfo->iconLocation = buf;
						linkInfo->iconIndex = iIcon;
						ret = true;
					}
					else
					{
						linkInfo->iconLocation.Empty();
						linkInfo->iconIndex = 0;
					}
				}
			}
            ppf->Release();
        }
        psl->Release();
//.........这里部分代码省略.........
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:101,代码来源:shellio.cpp

示例3: GetShortcutInfo

BOOL GetShortcutInfo(LPCTSTR path, CString& targetPath, 
                     HICON *largeIcon, HICON *smallIcon, CString *comment)
{
   // Get the attributes of the specified shortcut
   HRESULT hRes; 
   IShellLink* psl;
   CString iconFileName;
   int iconInd;
   SHFILEINFO inf;

   hRes = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); 
   if (SUCCEEDED(hRes))
   { 
      IPersistFile* ppf; 

      hRes = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); 

      if (SUCCEEDED(hRes))
      {
#ifndef UNICODE
         WCHAR wsz[BUFF_SIZE]; 
         MultiByteToWideChar(CP_ACP, 0, path, -1, wsz, BUFF_SIZE); 
         hRes = ppf->Load(wsz, STGM_READ);
#else
         hRes = ppf->Load(path, STGM_READ);
#endif
      }
      iconInd = 0;
      hRes = psl->GetPath(targetPath.GetBuffer(BUFF_SIZE), BUFF_SIZE, NULL, SLGP_RAWPATH);
      targetPath.ReleaseBuffer();
      if (!targetPath.IsEmpty())
         ExpEnvVars(targetPath);

      if (largeIcon && smallIcon)
      {
         hRes = psl->GetIconLocation(iconFileName.GetBuffer(BUFF_SIZE), BUFF_SIZE, &iconInd);
         iconFileName.ReleaseBuffer();
         if (!iconFileName.IsEmpty())
            ExpEnvVars(iconFileName);
         if (iconFileName.IsEmpty() && targetPath.IsEmpty())
         {
            SHGetFileInfo(path, 0, &inf, sizeof(inf), SHGFI_ICONLOCATION);
            iconFileName = inf.szDisplayName;
            iconInd = inf.iIcon;
         }
         if (iconFileName.IsEmpty())
         {
            GetFileIcons(targetPath, largeIcon, smallIcon);
         }
         else
         {
            if (iconInd == -1)
               iconInd = 0;
            hRes = ExtractIconEx(iconFileName, iconInd, largeIcon, smallIcon, 1);
            if (hRes == -1)
               GetFileIcons(path, largeIcon, smallIcon);
         }
      }

      if (comment)
      {
         *comment = GetFileNameComp(path, eFcName);
         CString descr;
         hRes = psl->GetDescription(descr.GetBuffer(BUFF_SIZE), BUFF_SIZE);
         descr.ReleaseBuffer();
         if (!descr.IsEmpty())
         {
            if (isdigit(comment->GetAt(0)) && isdigit(comment->GetAt(1)))
               *comment = EMPTY_CSTR;
            else
               *comment += CRLF;
            *comment += descr;
         }
      }

      ppf->Release(); 
      psl->Release();

   } 
   return TRUE; 
} 
开发者ID:plerup,项目名称:LaunchBar,代码行数:81,代码来源:utils.cpp


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