Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
// 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);
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
// 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; 
}
Ejemplo n.º 9
0
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);
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
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();
	}
}
Ejemplo n.º 12
0
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);
}
Ejemplo n.º 13
0
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;
}
Ejemplo n.º 14
0
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();
    }
}
Ejemplo n.º 15
0
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();
}
Ejemplo n.º 16
0
bool ShellIO::CreateLink(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))
        {
			if((flags & LI_DESCRIPTION) == LI_DESCRIPTION)
			{
				psl->SetDescription(linkInfo->description.GetBuffer());
			}

			if((flags & LI_PATH) == LI_PATH)
			{
				psl->SetPath(linkInfo->path.GetBuffer());
			}

			if((flags & LI_ARGUMENTS) == LI_ARGUMENTS)
			{
				psl->SetArguments(linkInfo->arguments.GetBuffer());
			}

			if((flags & LI_WORKDIRECTORY) == LI_WORKDIRECTORY)
			{
				psl->SetWorkingDirectory(linkInfo->workDirectory.GetBuffer());
			}

			if((flags & LI_ICONLOCATION) == LI_ICONLOCATION)
			{
				psl->SetIconLocation(linkInfo->iconLocation.GetBuffer(), linkInfo->iconIndex);
			}

			hRes = ppf->Save(fileName.GetBuffer(), FALSE);
			ret = SUCCEEDED(hRes);
         
            ppf->Release();
        }

        psl->Release();
	}

	return ret;
}
Ejemplo n.º 17
0
HRESULT CreateLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc) 
{ 
	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; 

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

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

		if (SUCCEEDED(hres)) 
		{ 
			WCHAR wsz[MAX_PATH]; 

			// Ensure that the string is Unicode. 
			MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH); 

			// TODO: Check return value from MultiByteWideChar to ensure 
			/*
			*					if(!IconLocation.IsEmpty())
			{
			hr = psl->SetIconLocation(IconLocation, IconIndex);	
			#ifdef _DEBUG
			if(FAILED(hr))
			TRACE("IconLocation not changed!\n");
			#endif
			}
			 */

				// Save the link by calling IPersistFile::Save. 
			hres = ppf->Save(wsz, TRUE); 
			ppf->Release(); 
		} 
		psl->Release(); 
	} 
	return hres; 
}
Ejemplo n.º 18
0
/* #FN#
   Uses the shell's IShellLink and IPersistFile interfaces 
   to create and store a shortcut to the specified object */
HRESULT
/* #AS#
   Result of calling member functions of the interfaces */
CWizardStep1::
CreateLink(
	LPCSTR lpszPathObj,  /* #IN# Address of a buffer containing the path of the object */
	LPCSTR lpszPathLink, /* #IN# Address of a buffer containing the path where the shell link is to be stored */
	LPCSTR lpszDesc      /* #IN# Address of a buffer containing the description of the shell link */
)
{
	HRESULT hResult;
	IShellLink* psl;

	// Get a pointer to the IShellLink interface. 
	hResult = CoCreateInstance( CLSID_ShellLink,
							 NULL, 
							 CLSCTX_INPROC_SERVER,
							 IID_IShellLink,
							 (LPVOID *)&psl );
	if( SUCCEEDED(hResult) )
	{
		IPersistFile *ppf;

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

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

		if( SUCCEEDED(hResult) )
		{
			WCHAR wsz[ MAX_PATH + 1 ];

			// Ensure that the string is Unicode. 
			MultiByteToWideChar( CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH );

			// Save the link by calling IPersistFile::Save.
			hResult = ppf->Save( wsz, TRUE );
			ppf->Release();
		}
		psl->Release();
	}
	return hResult;

} /* #OF# CWizardStep1::CreateLink */
Ejemplo n.º 19
0
HRESULT CreateShortcut(LPCSTR pszPathObj,LPSTR pszParam,LPSTR pszPath,LPSTR pszPathLink,LPSTR pszDesc)
{
	HRESULT hres; //调用 COM 接口方法之后的返回值
	IShellLink *pShellLink;
	IPersistFile *pPersistFile;
	WCHAR wsz[MAX_PATH]; //UNICODE串, 用来存放快捷方式文件名

	CoInitialize(NULL); //初始化 COM 库
	//创建 COM 对象并获取其实现的接口
	hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,IID_IShellLink,(void **)&pShellLink);
	if(FAILED(hres))
	{
		pShellLink ->Release(); //释放 IShellLink 接口
		CoUninitialize(); //关闭 COM 库, 释放所有 COM 资源
		return FALSE;
	}
	//设置快捷方式的各种属性
	pShellLink->SetPath(pszPathObj); //快捷方式所指的应用程序名
	pShellLink->SetArguments(pszParam); //参数
	pShellLink->SetDescription(pszDesc); //描述
	pShellLink->SetWorkingDirectory(pszPath); //设置工作目录
	//pShellLink->SetIconLocation("C:\\Icon.ico",0); //快捷方式的图标
	//pShellLink->SetHotkey(热键); //启动快捷方式的热键(只能是Ctrl+Alt+_)
	//pShellLink->SetShowCmd(SW_MAXIMIZE); //运行方式(常规窗口,最大化,最小化)
	//查询 IShellLink 接口从而得到 IPersistFile 接口来保存快捷方式
	hres = pShellLink->QueryInterface(IID_IPersistFile,(void **)&pPersistFile);
	if(FAILED(hres))
	{
		pPersistFile ->Release(); //释放 IPersistFile 接口
		pShellLink ->Release(); //释放 IShellLink 接口
		CoUninitialize(); //关闭 COM 库, 释放所有 COM 资源
		return(FALSE);
	}
	//转换 ANSI 串为 UNICODE 串(COM 内部使用 NUICODE)
	MultiByteToWideChar(CP_ACP, 0, pszPathLink, -1, wsz, MAX_PATH);
	//使用 IPersistFile 接口的 Save() 方法保存快捷方式
	hres = pPersistFile ->Save(wsz, TRUE);

	//释放 IPersistFile 接口
	pPersistFile ->Release();
	//释放 IShellLink 接口
	pShellLink ->Release();
	//关闭 COM 库, 释放所有 COM 资源
	CoUninitialize();
	return(hres);
}
HRESULT CreateLink(LPCTSTR lpszPathObj, LPCTSTR lpszPathLink, LPCTSTR lpszDesc) 
{ 
	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; 
 
		// Set the path to the shortcut target and add the description. 
		psl->SetPath(lpszPathObj); 
		psl->SetDescription(lpszDesc); 

 
		// Query IShellLink for the IPersistFile interface for saving the 
		// shortcut in persistent storage. 
		hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); 
 
		if (SUCCEEDED(hres))
		{
#if !( defined (_UNICODE) || defined(UNICODE) )
			size_t length = wxConvFile.ToWChar(NULL, 0, lpszPathLink);
			wchar_t * UnicodePath = new wchar_t [length];
			size_t res = wxConvFile.ToWChar(UnicodePath, length, lpszPathLink);
			(void)res; // warning fix when unicode=0 debug=0
			assert(res != wxCONV_FAILED);
#else
			const wchar_t *UnicodePath = lpszPathLink;
#endif
			// Save the link by calling IPersistFile::Save. 

			hres = ppf->Save(UnicodePath, TRUE); 
			ppf->Release(); 
#if !( defined (_UNICODE) || defined(UNICODE) )
			delete [] UnicodePath;
#endif

		} 
		psl->Release(); 
	} 
	return hres; 
}
Ejemplo n.º 21
0
//creates a shell link...in this example a Start Group item
HRESULT CreateShellLink(LPCSTR pszShortcutFile, LPSTR pszLink, LPSTR pszDesc)
{
    HRESULT hres;
    IShellLink* psl;

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

       // Query IShellLink for the IPersistFile interface for 
       // saving the shell link in persistent storage.
       hres = psl->QueryInterface(IID_IPersistFile,(void**)&ppf);
       if (SUCCEEDED(hres))
       {   
         WCHAR wsz[MAX_PATH];

         // Set the path to the shell link target.
         hres = psl->SetPath(pszShortcutFile);

         if (!SUCCEEDED(hres))
          MessageBox(NULL,"SetPath failed!","ERROR",MB_OK);

         // Set the description of the shell link.
         hres = psl->SetDescription(pszDesc);

         if (!SUCCEEDED(hres))
            MessageBox(NULL,"Set Description failed!","ERROR",MB_OK);

         // Ensure string is ANSI.
         MultiByteToWideChar(CP_ACP, 0, pszLink, -1, wsz, MAX_PATH);

         // Save the link via the IPersistFile::Save method.
         hres = ppf->Save(wsz, TRUE);
    
         // Release pointer to IPersistFile.
         ppf->Release();
       }
       // Release pointer to IShellLink.
       psl->Release();
    }
    return (hres==S_OK);
}
Ejemplo n.º 22
0
int create_shortcut(string src_path, string dst_path, string working_directory)
{
#ifdef _WIN32
	CoInitialize(NULL);
	IShellLink* pShellLink = NULL;
	HRESULT hres;
	hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_ALL,
		IID_IShellLink, (void**)&pShellLink);

	if (SUCCEEDED(hres))
	{
		pShellLink->SetPath(src_path.c_str());
		pShellLink->SetDescription("");
		pShellLink->SetIconLocation(src_path.c_str(), 0);
		pShellLink->SetWorkingDirectory(working_directory.c_str());

		IPersistFile *pPersistFile;
		hres = pShellLink->QueryInterface(IID_IPersistFile, (void**)&pPersistFile);

		if (SUCCEEDED(hres))
		{
			hres = pPersistFile->Save(CA2W(dst_path.c_str()), TRUE);
			pPersistFile->Release();
		}
		else
		{
			console_log("Error 2");
			return 2;
		}
		pShellLink->Release();
	}
	else
	{
		console_log("Error 1");
		return 1;
	}
	
#elif __APPLE__
	//todo: port to OSX
#endif

	return 0;
}
Ejemplo n.º 23
0
BOOL CreateShortcut(LPCTSTR linkPath, LPCTSTR targetPath, LPCTSTR comment, LPCTSTR arguments,
                    LPCTSTR workDir, LPCTSTR iconFile, int iconIndex, int showCommand)
{
   // Create a shortcut file
   HRESULT hRes; 
   IShellLink* psl; 

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

      psl->SetPath(targetPath); 
      if (arguments)
         psl->SetArguments(arguments);
      if (workDir)
         psl->SetWorkingDirectory(workDir);
      if (iconFile || iconIndex)
         psl->SetIconLocation(iconFile ? iconFile : targetPath, iconIndex);
      if (comment)
         psl->SetDescription(comment);

      psl->SetShowCmd(showCommand);

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

      if (SUCCEEDED(hRes))
      {
#ifndef UNICODE
         WCHAR wsz[BUFF_SIZE]; 
         MultiByteToWideChar(CP_ACP, 0, linkPath, -1, wsz, BUFF_SIZE); 

         hRes = ppf->Save(wsz, TRUE);
#else
         hRes = ppf->Save(linkPath, TRUE);
#endif
         ppf->Release(); 
      } 
      psl->Release(); 
   } 
   return TRUE; 
} 
Ejemplo n.º 24
0
HRESULT CreateLink(LPCSTR lpszPathLink, LPCSTR lpszPathObj, LPCSTR lpszDesc, LPCSTR lpszArgs) 
{ 
	HRESULT hres; 
	IShellLink* psl; 
 
	// 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); 
		if(lpszArgs) {
			psl->SetArguments(lpszArgs);
		}
		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)) 
		{ 
			WCHAR wsz[MAX_PATH]; 
 
			// Ensure that the string is Unicode. 
			MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH); 
			
			// Add code here to check return value from MultiByteWideChar 
			// for success.
 
			// Save the link by calling IPersistFile::Save. 
			hres = ppf->Save(wsz, TRUE); 
			ppf->Release(); 
		} 
		psl->Release(); 
	} 
	return hres; 
}
Ejemplo n.º 25
0
// @pymethod |PyIShellLink|SetDescription|Description of SetDescription.
PyObject *PyIShellLink::SetDescription(PyObject *self, PyObject *args)
{
	IShellLink *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	PyObject *obName;
	if ( !PyArg_ParseTuple(args, "O:SetDescription", &obName) )
		return NULL;
	TCHAR *pszName;
	if (!PyWinObject_AsTCHAR(obName, &pszName))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->SetDescription( pszName );
	PY_INTERFACE_POSTCALL;
	PyWinObject_FreeTCHAR(pszName);

	if ( FAILED(hr) )
		return OleSetOleError(hr);
	Py_INCREF(Py_None);
	return Py_None;
}
Ejemplo n.º 26
0
HRESULT ShellFunctions::CreateShortcut(LPCSTR pszShortcutFile,LPCSTR pszLink,LPCSTR pszDesc,LPCSTR pszParams)
{
	HRESULT hres;
	IShellLink* psl;
	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))
		{
			hres=psl->SetPath(pszLink);
			if (SUCCEEDED(hres))
			{
				LONG_PTR nIndex=LastCharIndex(pszLink,'\\');
				if (nIndex>=0)
				{
					char szWDir[MAX_PATH];
					MemCopy(szWDir,pszLink,nIndex);
					szWDir[nIndex]='\0';
					psl->SetWorkingDirectory(szWDir);
				}

				if (pszDesc!=NULL)
					psl->SetDescription(pszDesc);
				if (pszParams!=NULL)
					psl->SetArguments(pszParams);
				
				WCHAR wsz[MAX_PATH];
				MultiByteToWideChar(CP_ACP,0,pszShortcutFile,-1,wsz,MAX_PATH);
				hres=ppf->Save(wsz,TRUE);    
			}
			ppf->Release(); 
		}
		psl->Release();
	}
	return hres;
}
bool UIDesktopServices::createMachineShortcut(const QString & /* strSrcFile */, const QString &strDstPath, const QString &strName, const QUuid &uUuid)
{
    IShellLink *pShl = NULL;
    IPersistFile *pPPF = NULL;
    const QString strVBox = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/" + VBOX_GUI_VMRUNNER_IMAGE);
    QFileInfo fi(strVBox);
    QString strVBoxDir = QDir::toNativeSeparators(fi.absolutePath());
    HRESULT rc = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)(&pShl));
    if (FAILED(rc))
        return false;
    do
    {
        rc = pShl->SetPath(strVBox.utf16());
        if (FAILED(rc))
            break;
        rc = pShl->SetWorkingDirectory(strVBoxDir.utf16());
        if (FAILED(rc))
            break;
        QString strArgs = QString("--comment \"%1\" --startvm \"%2\"").arg(strName).arg(uUuid.toString());
        rc = pShl->SetArguments(strArgs.utf16());
        if (FAILED(rc))
            break;
        QString strDesc = QString("Starts the VirtualBox machine %1").arg(strName);
        rc = pShl->SetDescription(strDesc.utf16());
        if (FAILED(rc))
            break;
        rc = pShl->QueryInterface(IID_IPersistFile, (void**)&pPPF);
        if (FAILED(rc))
            break;
        QString strLink = QString("%1\\%2.lnk").arg(strDstPath).arg(strName);
        rc = pPPF->Save(strLink.utf16(), TRUE);
    } while(0);
    if (pPPF)
        pPPF->Release();
    if (pShl)
        pShl->Release();
    return SUCCEEDED(rc);
}
Ejemplo n.º 28
0
BOOL Shortcut_Create (LPTSTR pszTarget, LPCTSTR pszSource, LPTSTR pszDesc, LPTSTR pszArgs)
{
   IShellLink *psl;
   HRESULT rc = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
   if (SUCCEEDED (rc))
      {
      IPersistFile *ppf;
      rc = psl->QueryInterface (IID_IPersistFile, (void **)&ppf);
      if (SUCCEEDED (rc))
         { 
         rc = psl->SetPath (pszSource);
         if (SUCCEEDED (rc))
            {
            rc = psl->SetDescription (pszDesc ? pszDesc : pszSource);
            if (SUCCEEDED (rc))
               {
               if ( pszArgs )
                   rc = psl->SetArguments (pszArgs);
                   if (SUCCEEDED (rc))
                   {
#ifdef UNICODE
                   rc = ppf->Save (pszTarget, TRUE);
#else
                   WORD wsz[ MAX_PATH ];
                   MultiByteToWideChar (CP_ACP, 0, pszTarget, -1, (LPWSTR)wsz, MAX_PATH);
                   rc = ppf->Save ((LPCOLESTR)wsz, TRUE);
#endif
                   }
               }
            }
         ppf->Release ();
         }
      psl->Release ();
      }
   return SUCCEEDED(rc) ? TRUE : FALSE;
} 
Ejemplo n.º 29
0
BOOL CInstall::CreateShellLink(LPCSTR description, LPCSTR program,
                               LPCSTR arguments, LPCSTR icon, int nIconIndex)
{
    HRESULT hres;
    IShellLink* psl;
    CHAR szLink[MAXSTR];
    strcpy(szLink, m_szPrograms);
    strcat(szLink, "\\");
    strcat(szLink, m_szTargetGroup);
    strcat(szLink, "\\");
    strcat(szLink, description);
    strcat(szLink, ".LNK");
    AddMessage("Adding shell link\n   ");
    AddMessage(szLink);
    AddMessage("\n");

    // Ensure string is UNICODE.
    WCHAR wsz[MAX_PATH];
    MultiByteToWideChar(CP_ACP, 0, szLink, -1, wsz, MAX_PATH);

    // Save old shell link

    // Get a pointer to the IShellLink interface.
    hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                            IID_IShellLink, (void **)&psl);
    if (SUCCEEDED(hres))    {
        IPersistFile* ppf;
        // Query IShellLink for the IPersistFile interface.
        hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
        if (SUCCEEDED(hres))       {
            // Load the shell link.
            hres = ppf->Load(wsz, STGM_READ);
            if (SUCCEEDED(hres)) {
                // Resolve the link.
                hres = psl->Resolve(HWND_DESKTOP, SLR_ANY_MATCH);
                if (SUCCEEDED(hres)) {
                    // found it, so save details
                    CHAR szTemp[MAXSTR];
                    WIN32_FIND_DATA wfd;
                    int i;


                    fprintf(m_fLogOld, "Name=%s\n", szLink);
                    hres = psl->GetPath(szTemp, MAXSTR, (WIN32_FIND_DATA *)&wfd,
                                        SLGP_SHORTPATH );
                    if (SUCCEEDED(hres))
                        fprintf(m_fLogOld, "Path=%s\n", szTemp);
                    hres = psl->GetDescription(szTemp, MAXSTR);
                    if (SUCCEEDED(hres))
                        fprintf(m_fLogOld, "Description=%s\n", szTemp);
                    hres = psl->GetArguments(szTemp, MAXSTR);
                    if (SUCCEEDED(hres) && (szTemp[0] != '\0'))
                        fprintf(m_fLogOld, "Arguments=%s\n", szTemp);
                    hres = psl->GetWorkingDirectory(szTemp, MAXSTR);
                    if (SUCCEEDED(hres) && (szTemp[0] != '\0'))
                        fprintf(m_fLogOld, "Directory=%s\n", szTemp);
                    hres = psl->GetIconLocation(szTemp, MAXSTR, &i);
                    if (SUCCEEDED(hres) && (szTemp[0] != '\0')) {
                        fprintf(m_fLogOld, "IconLocation=%s\n", szTemp);
                        fprintf(m_fLogOld, "IconIndex=%d\n", i);
                    }
                    fprintf(m_fLogOld, "\n");
                }
            }
            // Release pointer to IPersistFile.
            ppf->Release();
        }
        // Release pointer to IShellLink.
        psl->Release();
    }


    // Save new shell link

    // Get a pointer to the IShellLink interface.
    hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                            IID_IShellLink, (void **)&psl);
    if (SUCCEEDED(hres))    {
        IPersistFile* ppf;
        // Query IShellLink for the IPersistFile interface for
        // saving the shell link in persistent storage.
        hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
        if (SUCCEEDED(hres)) {
            fprintf(m_fLogNew, "Name=%s\n", szLink);

            // Set the path to the shell link target.
            hres = psl->SetPath(program);
            if (!SUCCEEDED(hres))
                AddMessage("SetPath failed!");
            fprintf(m_fLogNew, "Path=%s\n", program);
            // Set the description of the shell link.
            hres = psl->SetDescription(description);
            if (!SUCCEEDED(hres))
                AddMessage("SetDescription failed!");
            fprintf(m_fLogNew, "Description=%s\n", description);
            if (arguments != (LPCSTR)NULL) {
                // Set the arguments of the shell link target.
                hres = psl->SetArguments(arguments);
                if (!SUCCEEDED(hres))
                    AddMessage("SetArguments failed!");
                fprintf(m_fLogNew, "Arguments=%s\n", arguments);
            }
            if (icon != (LPCSTR)NULL) {
                // Set the arguments of the shell link target.
                hres = psl->SetIconLocation(icon, nIconIndex);
                if (!SUCCEEDED(hres))
                    AddMessage("SetIconLocation failed!");
                fprintf(m_fLogNew, "IconLocation=%s\n", icon);
                fprintf(m_fLogNew, "IconIndex=%d\n", nIconIndex);
            }

            // Save the link via the IPersistFile::Save method.
            hres = ppf->Save(wsz, TRUE);
            // Release pointer to IPersistFile.
            ppf->Release();
        }
        // Release pointer to IShellLink.
        psl->Release();
        fprintf(m_fLogNew, "\n");
    }

    return (hres == 0);
}
void CBINDInstallDlg::ProgramGroup(BOOL create) {
	TCHAR path[MAX_PATH], commonPath[MAX_PATH], fileloc[MAX_PATH], linkpath[MAX_PATH];
	HRESULT hres; 
	IShellLink *psl = NULL; 
	LPMALLOC pMalloc = NULL;
	ITEMIDLIST *itemList = NULL;

	HRESULT hr = SHGetMalloc(&pMalloc);
	if (hr != NOERROR) {
		MessageBox("Could not get a handle to Shell memory object");
		return;
	}

	hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_COMMON_PROGRAMS, &itemList);
	if (hr != NOERROR) {
		MessageBox("Could not get a handle to the Common Programs folder");
		if (itemList) {
			pMalloc->Free(itemList);
		}
		return;
	}
	
	hr = SHGetPathFromIDList(itemList, commonPath);
	pMalloc->Free(itemList);

	if (create) {
		sprintf(path, "%s\\ISC", commonPath);
		CreateDirectory(path, NULL);
		
		sprintf(path, "%s\\ISC\\BIND", commonPath);
		CreateDirectory(path, NULL);

		hres = CoInitialize(NULL);

		if (SUCCEEDED(hres)) { 
			// Get a pointer to the IShellLink interface. 
			hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl); 
			if (SUCCEEDED(hres))
			{ 
				IPersistFile* ppf; 
				sprintf(linkpath, "%s\\BINDCtrl.lnk", path);
				sprintf(fileloc, "%s\\BINDCtrl.exe", m_binDir);
			
				psl->SetPath(fileloc); 
				psl->SetDescription("BIND Control Panel"); 

				hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf); 
				if (SUCCEEDED(hres)) { 
					WCHAR wsz[MAX_PATH]; 

					MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH); 
					hres = ppf->Save(wsz, TRUE); 
					ppf->Release(); 
				} 

				if (GetFileAttributes("readme.txt") != -1) {
					sprintf(fileloc, "%s\\Readme.txt", m_targetDir);
					sprintf(linkpath, "%s\\Readme.lnk", path);

					psl->SetPath(fileloc); 
					psl->SetDescription("BIND Readme"); 

					hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf); 
					if (SUCCEEDED(hres)) { 
						WCHAR wsz[MAX_PATH]; 

						MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH); 
						hres = ppf->Save(wsz, TRUE); 
						ppf->Release(); 
					} 
					psl->Release(); 
				}
			}
			CoUninitialize();
		} 
	}
	else {
		TCHAR filename[MAX_PATH];
		WIN32_FIND_DATA fd;

		sprintf(path, "%s\\ISC\\BIND", commonPath);

		sprintf(filename, "%s\\*.*", path);
		HANDLE hFind = FindFirstFile(filename, &fd);
		if (hFind != INVALID_HANDLE_VALUE) {
			do {
				if (strcmp(fd.cFileName, ".") && strcmp(fd.cFileName, "..")) {
					sprintf(filename, "%s\\%s", path, fd.cFileName);
					DeleteFile(filename);
				}
			} while (FindNextFile(hFind, &fd));
			FindClose(hFind);
		}
		RemoveDirectory(path);
		sprintf(path, "%s\\ISC", commonPath);
		RemoveDirectory(path);
	}
}