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


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

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


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

示例1: wprintf

HRESULT
CreateLink(LPCWSTR aTargetPath, LPCWSTR aShortcutPath, LPCWSTR aDescription) 
{ 
    HRESULT hres;
    IShellLink* psl;
 
    wprintf(L"creating shortcut: '%s'\n",  aShortcutPath);

    CoInitialize(nullptr);

    hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
                            IID_IShellLink, (LPVOID*)&psl);
    if (FAILED(hres)) {
      CoUninitialize();
      return hres;
    }
    psl->SetPath(aTargetPath);
    if (aDescription) {
      psl->SetDescription(aDescription);
    } else {
      psl->SetDescription(L"");
    }
 
    IPersistFile* ppf = nullptr;
    hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
 
    if (SUCCEEDED(hres)) {
        hres = ppf->Save(aShortcutPath, TRUE);
        ppf->Release();
    }
    psl->Release();
    CoUninitialize();
    return hres;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:34,代码来源:linktool.cpp

示例2: CreateLink

long CreateLink(LPCSTR lpszPathObj,LPSTR lpszPathLink,LPSTR lpszDesc)
{
	HRESULT hres;
	IShellLink* psl;
    
	CoInitialize(NULL);
	hres = CoCreateInstance(CLSID_ShellLink, NULL, 
        CLSCTX_INPROC_SERVER, IID_IShellLink,(void**)&psl); 
    if (SUCCEEDED(hres)) 
	{
		IPersistFile *ppf;
		hres = psl->QueryInterface (IID_IPersistFile, (void **)&ppf);
		if (SUCCEEDED(hres)) 
		{ 
            WCHAR wsz[MAX_PATH];
			ZeroMemory(wsz,sizeof(WORD)*MAX_PATH);
			hres = psl->SetPath(lpszPathObj); 
			hres = psl->SetDescription(lpszDesc);  
       		hres = psl->SetIconLocation(lpszPathObj,0);
			MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH);
			hres = ppf->Save(wsz, TRUE); 
            ppf->Release();
			if(!SUCCEEDED(hres))
				return false;
		} 
		else
			return false;
        psl->Release();
	}
	else
		return false;
	CoUninitialize();
	return true;
}
开发者ID:rauls,项目名称:iReporter,代码行数:34,代码来源:createshortcuts.cpp

示例3: CreateLink

HRESULT CSysDialog::CreateLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc)
{
    HRESULT hres;
    IShellLink* psl;

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

        psl->SetPath(lpszPathObj);
        psl->SetDescription(lpszDesc);
        hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
        if (SUCCEEDED(hres)) {
            WCHAR wsz[MAX_PATH];
            
            MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH);
            hres = ppf->Save(wsz, TRUE);
            ppf->Release();
        }
        psl->Release();
    }
    return hres;
}
开发者ID:2Dou,项目名称:PlayBox,代码行数:25,代码来源:DlgSys.cpp

示例4: Create

bool CShortCut::Create(void)
{
    bool results;
    HRESULT hres;
    IShellLink *psl;
    IPersistFile *ppf;
    wchar_t wsz[MAX_PATH];
    CoInitialize(NULL);
    hres = CoCreateInstance(CLSID_ShellLink, NULL,
    CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);
    results=false;
    if (SUCCEEDED(hres))
    {
        psl->SetPath(LinkFile.c_str());
        psl->SetWorkingDirectory(LinkPath.c_str());
        psl->SetDescription(LinkDescription.c_str());
        hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
        if (SUCCEEDED(hres))
        {
            MultiByteToWideChar(CP_ACP, 0, FileName.c_str(), -1,
            wsz, MAX_PATH);
            hres = ppf->Save(wsz, true);
            ppf->Release();
            results=true;
        }
        psl->Release();
    }
    CoUninitialize();
    return results;
}
开发者ID:loguntsov,项目名称:timer,代码行数:30,代码来源:ShortCutClass.cpp

示例5: CreateLink

static HRESULT CreateLink(LPCTSTR lpszPathObj, LPCTSTR lpszPathLink,
                   LPCTSTR pszArgs, LPCTSTR lpszDesc, LPCTSTR lpszWdir)
{    
   HRESULT h_result;    
   IShellLink* psl;     
   CoInitialize( NULL );    
   h_result = CoCreateInstance(CLSID_ShellLink, NULL,    
      CLSCTX_INPROC_SERVER, 
      IID_IShellLink, 
      (LPVOID *) &psl);    
   if (SUCCEEDED(h_result))
   {        
      IPersistFile* ppf;         
      psl->SetPath(lpszPathObj);        
      psl->SetArguments(pszArgs);        
      psl->SetDescription(lpszDesc);         
      psl->SetWorkingDirectory(lpszWdir);
      h_result = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);         
      if (SUCCEEDED(h_result))
      {            
         h_result = ppf->Save(lpszPathLink, TRUE);
         ppf->Release();        
      }        
      psl->Release();    
   }    
   return h_result;
}
开发者ID:lazyrun,项目名称:pokerbot,代码行数:27,代码来源:Wizard.cpp

示例6: my_createshortcut

// http://msdn.microsoft.com/en-us/library/aa969393.aspx
bool my_createshortcut(const TCHAR *source, const TCHAR *target, const TCHAR *description) 
{ 
    HRESULT hres; 
    IShellLink* psl;
	TCHAR tmp[MAX_DPATH];
 
    // Get a pointer to the IShellLink interface. It is assumed that CoInitialize
    // has already been called.
    hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); 
    if (SUCCEEDED(hres)) 
    { 
        IPersistFile* ppf; 
 
        // Set the path to the shortcut target and add the description. 
        psl->SetPath(target); 
        psl->SetDescription(description); 
 
        // Query IShellLink for the IPersistFile interface, used for saving the 
        // shortcut in persistent storage. 
        hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); 
 
        if (SUCCEEDED(hres)) 
        { 
            // Save the link by calling IPersistFile::Save. 
			_tcscpy (tmp, source);
			const TCHAR *ext = _tcsrchr (tmp, '.');
			if (!ext || _tcsicmp (ext, _T(".lnk")) != 0)
				_tcscat (tmp, _T(".lnk"));
            hres = ppf->Save(tmp, TRUE); 
            ppf->Release(); 
        } 
        psl->Release(); 
    }
	return SUCCEEDED(hres);
}
开发者ID:engur,项目名称:WinUAE,代码行数:36,代码来源:fsdb_mywin32.cpp

示例7: CreateLinkToFile

HRESULT CreateLinkToFile(TCHAR *PathToFile,TCHAR *PathToLink,TCHAR *LinkDescription)
{
	IShellLink		*pShellLink = NULL;
	IPersistFile	*pPersistFile = NULL;
	WCHAR			PathToLinkW[MAX_PATH];
	HRESULT			hr;

	hr = CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,
	IID_IShellLink,(LPVOID*)&pShellLink);

	if(SUCCEEDED(hr))
	{
		pShellLink->SetPath(PathToFile);
		pShellLink->SetDescription(LinkDescription);

		hr = pShellLink->QueryInterface(IID_IPersistFile,(LPVOID*)&pPersistFile);

		if(SUCCEEDED(hr))
		{
			#ifndef UNICODE
			MultiByteToWideChar(CP_ACP,0,PathToLink,-1,PathToLinkW,MAX_PATH);
			#else
			StringCchCopy(PathToLinkW,SIZEOF_ARRAY(PathToLinkW),PathToLink);
			#endif

			pPersistFile->Save(PathToLinkW,TRUE);

			pPersistFile->Release();
		}

		pShellLink->Release();
	}

	return hr;
}
开发者ID:yellowbigbird,项目名称:bird-self-lib,代码行数:35,代码来源:FileOperations.c

示例8: CreateLink

// http://msdn.microsoft.com/en-us/library/aa969393.aspx
HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) { 
	HRESULT hres; 
	IShellLink* psl; 
	CoInitialize(0);

	// Get a pointer to the IShellLink interface. It is assumed that CoInitialize
	// has already been called.
	hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); 
	if (SUCCEEDED(hres)) { 
		IPersistFile* ppf; 

		// Set the path to the shortcut target and add the description. 
		psl->SetPath(lpszPathObj); 
		psl->SetArguments(lpszArguments);
		psl->SetDescription(lpszDesc); 

		// Query IShellLink for the IPersistFile interface, used for saving the 
		// shortcut in persistent storage. 
		hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); 

		if (SUCCEEDED(hres)) { 
			// Save the link by calling IPersistFile::Save. 
			hres = ppf->Save(lpszPathLink, TRUE); 
			ppf->Release(); 
		} 
		psl->Release(); 
	}
	CoUninitialize();

	return hres; 
}
开发者ID:ANR2ME,项目名称:ppsspp,代码行数:32,代码来源:WindowsHost.cpp

示例9: CreateShellLink

bool CreateShellLink(const char *filepath, const char *linkpath, const char *desc, int icon)
{
	HRESULT hres;
	IShellLink* psl;
	IPersistFile* ppf;
	hres = CoInitialize(NULL);
	hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
	                        (PVOID *) &psl);
	if(SUCCEEDED(hres)) {
		psl->SetPath(filepath);
		psl->SetDescription(desc);
		if(icon >= 0)
			psl->SetIconLocation(filepath, icon);
		hres = psl->QueryInterface(IID_IPersistFile, (PVOID *) &ppf);
		if (SUCCEEDED(hres)) {
			WCHAR szPath[_MAX_PATH] = { 0 };
			MultiByteToWideChar(CP_ACP, 0, linkpath, strlen(linkpath), szPath, _MAX_PATH);
			hres = ppf->Save(szPath, TRUE);
			ppf->Release();
		}
	}
	psl->Release();
	CoUninitialize();
	return SUCCEEDED(hres);
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:25,代码来源:Shell.cpp

示例10: CreateLink

bool CreateLink(std::string& path, std::string& linkPath, std::string& description) 
{ 
	HRESULT hres; 
	IShellLink* psl; 
 
	// Get a pointer to the IShellLink interface. 
	hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); 
	if (SUCCEEDED(hres)) 
	{ 
		IPersistFile* ppf; 
		wstring pathW = KrollUtils::UTF8ToWide(path);
		wstring linkPathW = KrollUtils::UTF8ToWide(linkPath);
		wstring descriptionW = KrollUtils::UTF8ToWide(description);
 
		// Set the path to the shortcut target and add the description. 
		psl->SetPath(pathW.c_str()); 
		psl->SetDescription(descriptionW.c_str()); 
 
		// Query IShellLink for the IPersistFile interface for saving the 
		// shortcut in persistent storage. 
		hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*) &ppf); 
 
		if (SUCCEEDED(hres)) 
		{ 
			// Save the link by calling IPersistFile::Save. 
			hres = ppf->Save(linkPathW.c_str(), TRUE); 
			ppf->Release(); 
			return true;
		} 
		psl->Release(); 
	} 
	return false;
}
开发者ID:leongersing,项目名称:titanium_desktop,代码行数:33,代码来源:main.cpp

示例11: createShortcut

void FileSystemManager::createShortcut(QString shortcutFilePath, QString pathToTarget, QString desc)
{
	HRESULT hres = NULL;
	IShellLink * psl = NULL;
	IPersistFile * ppf = NULL;
	
	QDir workingDirectory = scnManager->getWorkingDirectory();
	QDir linkPath = workingDirectory / shortcutFilePath;

	// Get a pointer to the IShellLink interface.
	hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &psl);

	if (SUCCEEDED(hres))
	{
		// Set the path to the shortcut target
		psl->SetPath((LPCWSTR) pathToTarget.utf16());
		psl->SetDescription((LPCWSTR) desc.utf16());

		// Query IShellLink for the IPersistFile interface for
		// saving the shortcut in persistent storage.
		hres = psl->QueryInterface(IID_IPersistFile, (void **) &ppf);

		if (SUCCEEDED(hres))
		{
			// Save the link by calling IPersistFile::Save.
			hres = ppf->Save((LPCOLESTR) native(linkPath).utf16(), TRUE);
			ppf->Release();
		}

		psl->Release();
	}
}
开发者ID:DX94,项目名称:BumpTop,代码行数:32,代码来源:BT_FileSystemManager.cpp

示例12: CreateFileShortcut

BOOL CreateFileShortcut(LPCWSTR lpszFileName, LPCWSTR lpszLnkFileDir, LPCWSTR lpszLnkFileName, LPCWSTR lpszWorkDir, WORD wHotkey, LPCTSTR lpszDescription, int iShowCmd)
{
	if (lpszLnkFileDir == NULL)
		return FALSE;

	HRESULT hr;
	IShellLink     *pLink;  //IShellLink对象指针  
	IPersistFile   *ppf; //IPersisFil对象指针  

						 //创建IShellLink对象  
	hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pLink);
	if (FAILED(hr))
		return FALSE;

	//从IShellLink对象中获取IPersistFile接口  
	hr = pLink->QueryInterface(IID_IPersistFile, (void**)&ppf);
	if (FAILED(hr))
	{
		pLink->Release();
		return FALSE;
	}

	//目标  
	if (lpszFileName == NULL)
		pLink->SetPath(_wpgmptr);
	else
		pLink->SetPath(lpszFileName);

	//工作目录  
	if (lpszWorkDir != NULL)
		pLink->SetWorkingDirectory(lpszWorkDir);

	//快捷键  
	if (wHotkey != 0)
		pLink->SetHotkey(wHotkey);

	//备注  
	if (lpszDescription != NULL)
		pLink->SetDescription(lpszDescription);

	//显示方式  
	pLink->SetShowCmd(iShowCmd);


	//快捷方式的路径 + 名称  
	wchar_t szBuffer[MAX_PATH];
	if (lpszLnkFileName != NULL) //指定了快捷方式的名称  
		wsprintf(szBuffer, L"%s\\%s", lpszLnkFileDir, lpszLnkFileName);
	//保存快捷方式到指定目录下  

	hr = ppf->Save(szBuffer, TRUE);

	ppf->Release();
	pLink->Release();
	return SUCCEEDED(hr);
}
开发者ID:w1146869587,项目名称:duicefktv,代码行数:56,代码来源:Daemon.cpp

示例13: _CreateShellLink

HRESULT _CreateShellLink(PCSTR pszArguments, PCWSTR pszTitle, LPCSTR szDescription, IShellLink **ppsl)
{
    IShellLink *psl;
    HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl));
    if (SUCCEEDED(hr))
    {
        // Determine our executable's file path so the task will execute this application
        CHAR szAppPath[MAX_PATH];
        if (GetModuleFileName(NULL, szAppPath, ARRAYSIZE(szAppPath)))
        {
            hr = psl->SetPath(szAppPath);
            if (SUCCEEDED(hr))
            {
                hr = psl->SetArguments(pszArguments);
                if (SUCCEEDED(hr))
                {
					hr = psl->SetDescription( szDescription );
					if (SUCCEEDED(hr))
					{
						// The title property is required on Jump List items provided as an IShellLink
						// instance.  This value is used as the display name in the Jump List.
						IPropertyStore *pps;
						hr = psl->QueryInterface(IID_PPV_ARGS(&pps));
						if (SUCCEEDED(hr))
						{
							PROPVARIANT propvar;
							hr = InitPropVariantFromString(pszTitle, &propvar);
							if (SUCCEEDED(hr))
							{
								hr = pps->SetValue(PKEY_Title, propvar);
								if (SUCCEEDED(hr))
								{
									hr = pps->Commit();
									if (SUCCEEDED(hr))
									{
										hr = psl->QueryInterface(IID_PPV_ARGS(ppsl));
									}
								}
								PropVariantClear(&propvar);
							}
							pps->Release();
						}
					}
                }
            }
        }
        else
        {
            hr = HRESULT_FROM_WIN32(GetLastError());
        }
        psl->Release();
    }
    return hr;
}
开发者ID:LBRGeorge,项目名称:vcmpserverbrowser,代码行数:54,代码来源:Win7.cpp

示例14: onFileCreateProjectShortcut

void UiPlayer::onFileCreateProjectShortcut(void)
{
    WCHAR shortcutPathBuff[MAX_PATH + 1] = {0};

    OPENFILENAME ofn = {0};
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner   = m_hwnd;
    ofn.lpstrFilter = L"Shortcut (*.lnk)\0*.lnk\0";
    ofn.lpstrTitle  = L"Create Project Shortcut";
    ofn.Flags       = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
    ofn.lpstrFile   = shortcutPathBuff;
    ofn.nMaxFile    = MAX_PATH;

    if (!GetSaveFileName(&ofn)) return;

    // Get a pointer to the IShellLink interface. It is assumed that CoInitialize
    // has already been called.
    IShellLink* psl;
    HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl);

    if (SUCCEEDED(hres))
    {
        IPersistFile* ppf;

        // args
        string args = m_project.makeCommandLine();

        // Set the path to the shortcut target and add the description.
        psl->SetPath(__wargv[0]);
        wstring wargs;
        wargs.assign(args.begin(), args.end());
        psl->SetArguments(wargs.c_str());
        psl->SetDescription(L"UiPlayer");

        // Query IShellLink for the IPersistFile interface, used for saving the
        // shortcut in persistent storage.
        hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);

        if (SUCCEEDED(hres))
        {
            // Save the link by calling IPersistFile::Save.
            size_t len = wcslen(shortcutPathBuff);
            if (_wcsicmp(shortcutPathBuff + len - 4, L".lnk") != 0)
            {
                wcscat_s(shortcutPathBuff, L".lnk");
            }
            hres = ppf->Save(shortcutPathBuff, TRUE);
            ppf->Release();
        }
        psl->Release();
    }
}
开发者ID:evamango,项目名称:quick-MornUI,代码行数:52,代码来源:ui.cpp

示例15: createLinks

void createLinks(const std::string name, const std::string &exe)
{
  CoInitialize(NULL);
  HRESULT res;
  IShellLink *lnk = NULL;

  res = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                         IID_IShellLink, reinterpret_cast<void**>(&lnk));
  if(!SUCCEEDED(res))
    fail("Couldn't create shortcut links");

  lnk->SetPath(exe.c_str());
  lnk->SetDescription(name.c_str());
  //lnk->SetIconLocation("where", 0);

  IPersistFile *pf = NULL;
  res = lnk->QueryInterface(IID_IPersistFile, reinterpret_cast<void**>(&pf));
  if(!SUCCEEDED(res))
    {
      lnk->Release();
      fail("Couldn't create shortcut links");
    }

  // Use this for links you don't want to highlight, ie. everything
  // except the main program link. May need some rewriting.
  /*
  PROPVARIANT pvar;
  pvar.vt = VT_BOOL;
  pvar.boolVal = VARIANT_TRUE;
  pf->SetValue(PKEY_AppUserModel_ExcludeFromShowInNewInstall, pvar);
  */

  std::string lname = name + ".lnk";

  // Save desktop link
  fs::path link = getPathCSIDL(CSIDL_DESKTOPDIRECTORY) / lname;
  pf->Save(toWide(link.string()), TRUE);

  // Create start menu directory
  link = getPathCSIDL(CSIDL_PROGRAMS) / name;
  fs::create_directories(link);

  // Save the start menu link
  link /= lname;
  pf->Save(toWide(link.string()), TRUE);

  pf->Release();
  lnk->Release();
}
开发者ID:cooljeanius,项目名称:Tiggit,代码行数:49,代码来源:win32_setup.cpp


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