Exemple #1
0
void CSettingsPage::OnChangetemp()
{
	TCHAR fn[MAX_PATH];
	LPITEMIDLIST idl,idlroot;
	IMalloc *mal;

	SHGetSpecialFolderLocation(m_hWnd, CSIDL_DRIVES, &idlroot);
	SHGetMalloc(&mal);
	BROWSEINFO bi = { m_hWnd, idlroot, fn, _T("Select folder for CVS temporary files.  This folder must be writeable by all users that wish to use CVS."), BIF_NEWDIALOGSTYLE|BIF_RETURNONLYFSDIRS|BIF_RETURNFSANCESTORS, BrowseValid };
	idl = SHBrowseForFolder(&bi);

	mal->Free(idlroot);
	if(!idl)
	{
		mal->Release();
		return;
	}

	SHGetPathFromIDList(idl,fn);

	mal->Free(idl);
	mal->Release();

	m_edTempDir.SetWindowText(fn);

	SetModified();
}
string pBrowserWindow::directory(BrowserWindow::State& state) {
  wchar_t wname[PATH_MAX + 1] = L"";

  BROWSEINFO bi;
  bi.hwndOwner = state.parent ? state.parent->p.hwnd : 0;
  bi.pidlRoot = NULL;
  bi.pszDisplayName = wname;
  bi.lpszTitle = L"\nChoose a directory:";
  bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
  bi.lpfn = BrowserWindowCallbackProc;
  bi.lParam = (LPARAM)&state;
  bi.iImage = 0;
  bool result = false;
  LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
  if(pidl) {
    if(SHGetPathFromIDList(pidl, wname)) {
      result = true;
      IMalloc *imalloc = 0;
      if(SUCCEEDED(SHGetMalloc(&imalloc))) {
        imalloc->Free(pidl);
        imalloc->Release();
      }
    }
  }
  if(result == false) return "";
  string name = (const char*)utf8_t(wname);
  if(!name) return "";
  name.transform("\\", "/");
  if(name.endsWith("/") == false) name.append("/");
  return name;
}
void CSnapperOptions::OnBnClickedBrowseNotebook()
{
	BROWSEINFO sBi = { 0 };
	/*
    sBi.lpszTitle = TEXT("Select Notebook(s)");
	sBi.hwndOwner = m_hWndTop;
	sBi.iImage = 
	*/
    LPITEMIDLIST pIdl = SHBrowseForFolder ( &sBi );
    if ( pIdl != NULL )
    {
        // get the name of the folder
        TCHAR pszNotebookPath[MAX_PATH];
        if ( SHGetPathFromIDList ( pIdl, pszNotebookPath ) )
        {
			m_strNotebookPath = pszNotebookPath;
			m_bUpdateHotlists = TRUE;
			UpdateData(FALSE);
        }

        // free memory 
        IMalloc * piMalloc = NULL;
        if ( SUCCEEDED( SHGetMalloc ( &piMalloc )) )
        {
            piMalloc->Free ( pIdl );
            piMalloc->Release ( );
        }

    }
	
}
Exemple #4
0
/*
	ディレクトリダイアログ用汎用ルーチン
*/
void BrowseDirDlg(TWin *parentWin, UINT editCtl, char *title)
{ 
	IMalloc			*iMalloc = NULL;
	BROWSEINFO		brInfo;
	LPITEMIDLIST	pidlBrowse;
	char			fileBuf[MAX_PATH];

	parentWin->GetDlgItemText(editCtl, fileBuf, sizeof(fileBuf));
	if (!SUCCEEDED(SHGetMalloc(&iMalloc)))
		return;

	TBrowseDirDlg	dirDlg(fileBuf);
	brInfo.hwndOwner = parentWin->hWnd;
	brInfo.pidlRoot = 0;
	brInfo.pszDisplayName = fileBuf;
	brInfo.lpszTitle = title;
	brInfo.ulFlags = BIF_RETURNONLYFSDIRS;
	brInfo.lpfn = BrowseDirDlg_Proc;
	brInfo.lParam = (LPARAM)&dirDlg;
	brInfo.iImage = 0;

	do {
		if ((pidlBrowse = ::SHBrowseForFolder(&brInfo)) != NULL) {
			if (::SHGetPathFromIDList(pidlBrowse, fileBuf))
				::SetDlgItemText(parentWin->hWnd, editCtl, fileBuf);
			iMalloc->Free(pidlBrowse);
			break;
		}
	} while (dirDlg.IsDirty());

	iMalloc->Release();
}
const char *iTunesLibrary::GetMusicLibraryXMLFileName(std::string &buf)
{
#if defined(WIN32)
	TCHAR szPath[_MAX_PATH];
    LPITEMIDLIST pidl;
	IMalloc *pMalloc;

	szPath[0] = '\0';
	SHGetMalloc( &pMalloc );
    if(SHGetSpecialFolderLocation(NULL, CSIDL_MYMUSIC, &pidl) == S_OK)
    { 
        SHGetPathFromIDList(pidl,szPath);
        pMalloc->Free(pidl);
    }
    pMalloc->Release();

	buf = szPath;
	buf += "\\";
	buf += ITUNES_XML_DIR_NAME;
	buf += "\\";
	buf += ITUNES_XML_FILE_NAME;
#else
#endif
	return buf.c_str();
}
Exemple #6
0
LRESULT DiskDialog::chooseDir(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	BROWSEINFO bi = { 0 };
    bi.lpszTitle = "Directory to Monitor...";
	bi.hwndOwner = m_hWnd;
    LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
    if ( pidl != 0 )
    {
        // get the name of the folder
        TCHAR path[MAX_PATH];
        SHGetPathFromIDList ( pidl, path );
		SetDlgItemText(IDC_DIRECTORY, path);
		pMeter->put_Path(_bstr_t(path));

        // free memory used
        IMalloc * imalloc = 0;
        if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
        {
            imalloc->Free ( pidl );
            imalloc->Release ( );
        }

		return S_OK;
	}

	return S_OK;
}
		const Path Browser::SelectDirectory()
		{
			Path path;
			path.Reserve( MAX_PATH*2 );

			Object::Pod<BROWSEINFO> bi;

			bi.hwndOwner      = Application::Instance::GetActiveWindow();
			bi.pszDisplayName = path.Ptr();
			bi.ulFlags        = BIF_RETURNONLYFSDIRS;

			if (LPITEMIDLIST const idl = ::SHBrowseForFolder( &bi ))
			{
				if (::SHGetPathFromIDList( idl, path.Ptr() ) && path.Validate())
					path.MakePretty( true );
				else
					path.Clear();

				IMalloc* pMalloc;

				if (SUCCEEDED(::SHGetMalloc( &pMalloc )))
				{
					pMalloc->Free( idl );
					pMalloc->Release();
				}
			}
			else
			{
				path.Clear();
			}

			return path;
		}
Exemple #8
0
/*
	ディレクトリダイアログ用汎用ルーチン
*/
BOOL BrowseDirDlg(TWin *parentWin, const char *title, const char *defaultDir, char *buf)
{ 
	IMalloc			*iMalloc = NULL;
	BROWSEINFOW		brInfo;
	LPITEMIDLIST	pidlBrowse;
	BOOL			ret = FALSE;
	Wstr			buf_w(MAX_PATH), defaultDir_w(MAX_PATH), title_w(title);

	if (!SUCCEEDED(SHGetMalloc(&iMalloc)))
		return FALSE;

	U8toW(defaultDir, defaultDir_w.Buf(), MAX_PATH);
	brInfo.hwndOwner = parentWin->hWnd;
	brInfo.pidlRoot = 0;
	brInfo.pszDisplayName = buf_w.Buf();
	brInfo.lpszTitle = title_w;
	brInfo.ulFlags = BIF_RETURNONLYFSDIRS;
	brInfo.lpfn = BrowseDirDlgProc;
	brInfo.lParam = (LPARAM)defaultDir_w.Buf();
	brInfo.iImage = 0;

	if ((pidlBrowse = SHBrowseForFolderV((BROWSEINFO *)&brInfo)))
	{
		ret = SHGetPathFromIDListV(pidlBrowse, buf_w.Buf());
		iMalloc->Free(pidlBrowse);
		if (ret)
			WtoU8(buf_w, buf, MAX_PATH_U8);
	}

	iMalloc->Release();
	return	ret;
}
Exemple #9
0
// Дать пользователю выбрать каталог
int BrowseForFolder(TCHAR *prompt, TCHAR *in_filename, TCHAR *out_filename)
{
  BROWSEINFO bi;
  bi.hwndOwner = GetActiveWindow();
  bi.lParam = (LONG)in_filename;
  bi.lpszTitle = prompt;
  bi.lpfn = BrowseCallbackProc;
  bi.pidlRoot = NULL;
  bi.pszDisplayName = out_filename;
  bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;

  LPITEMIDLIST pItemIdList = SHBrowseForFolder(&bi);

  int result = 0;
  if(pItemIdList != NULL)
  {
    if (SHGetPathFromIDList(pItemIdList, out_filename))
      result = 1;

    IMalloc *iMalloc = 0;
    if(SUCCEEDED(SHGetMalloc(&iMalloc)))
    {
      iMalloc->Free(pItemIdList);
      iMalloc->Release();
    }
  }
  return result;
}
Exemple #10
0
void ConfigDlg::OnBnClickedOpenDir()
{
	// TODO: 在此添加控件通知处理程序代码
	char szDisplayName[_MAX_PATH];
	BROWSEINFO bi;
	ZeroMemory(&bi, sizeof(BROWSEINFO));
	bi.hwndOwner = m_hWnd;
	bi.pszDisplayName = (LPWSTR)szDisplayName;
	bi.lpszTitle = (LPCWSTR)"选择一个文件夹";
	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
	BOOL bRet = FALSE;
	TCHAR szFolder[MAX_PATH * 2];
	szFolder[0] = _T('\0');
	if (pidl)
	{
		if (SHGetPathFromIDList(pidl, szFolder))
			bRet = TRUE;
		IMalloc *pMalloc = NULL;
		if (SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc)
		{
			pMalloc->Free(pidl);
			pMalloc->Release();
		}
	}

	m_EditDir.Format(_T("%s%s"), szFolder, "\\");  //选择的文件夹路径
	UpdateData(FALSE);
}
Exemple #11
0
/**
 *\fn           std::string CLSIDToProgID(const char *clsid)
 *\brief        将CLSID转成类名,CLSID例:{2D7E0F8F-3215-11D0-BF28-0000E8D0D146}
 *\param[in]    const char * clsid 
 *\return       std::string 类名
 */
std::string CAddinProcess::CLSIDToProgID(const char *clsid)
{
    if (NULL == clsid) return "";

    USES_CONVERSION;
    CLSID clsid_data = {0};
    OLECHAR clsid_wstr[100] = {0};
    LPOLESTR prog_id = NULL;

    wcscpy(clsid_wstr, CT2OLE(clsid));

    HRESULT hr = CLSIDFromString(clsid_wstr, &clsid_data);

    if (FAILED(hr)) return "";

    hr = ProgIDFromCLSID(clsid_data, &prog_id);

    if (FAILED(hr)) return "";

    LPCTSTR lpstr =  OLE2CT(prog_id);

    std::string out(lpstr);

    IMalloc * pMalloc = NULL;

    hr = ::CoGetMalloc(1, &pMalloc);   // 取得 IMalloc

    if (SUCCEEDED(hr))
    {
        pMalloc->Free(prog_id);        // 释放ProgID内存
        pMalloc->Release();            // 释放IMalloc
    }

    return out;
}
void BrowseFolder( char drive , std::string drive_type ) {
#if !defined(HX_DOS)
	if (Drives[drive-'A']) {
		LOG_MSG("Unmount drive %c first, and then try again.",drive);
		return;
	}
	std::string title = "Select a drive/directory to mount";
	char path[MAX_PATH];
	BROWSEINFO bi = { 0 };
	if(drive_type=="CDROM")
		bi.lpszTitle = ( title + " CD-ROM\nMounting a directory as CD-ROM gives an limited support" ).c_str();
	else if(drive_type=="FLOPPY")
		bi.lpszTitle = ( title + " as Floppy" ).c_str();
	else if(drive_type=="LOCAL")
		bi.lpszTitle = ( title + " as Local").c_str();
	else
		bi.lpszTitle = (title.c_str());
	LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );

	if ( pidl != 0 ) {
		SHGetPathFromIDList ( pidl, path );
//		SetCurrentDirectory ( path );
		SearchFolder( path , drive, drive_type );
		IMalloc * imalloc = 0;
		if ( SUCCEEDED( SHGetMalloc ( &imalloc )) ) {
			imalloc->Free ( pidl );
			imalloc->Release ( );
		}
	}
#endif
}
	void IntroDialog::InstallLocationClicked()
	{
		BROWSEINFO bi = { 0 };
		bi.lpszTitle =  (LPCWSTR) L"Pick installation directory";
		LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
		if (pidl != 0)
		{
			TCHAR pathW[MAX_PATH];
			if (SHGetPathFromIDList(pidl, pathW))
			{
				std::string path = KrollUtils::WideToUTF8(pathW);
				appInstallPath = FileUtils::Join(path.c_str(), app->name.c_str(), NULL);
				std::wstring wideAppInstallPath = KrollUtils::UTF8ToWide(appInstallPath);
				SendMessage(installLocationText, WM_SETTEXT, 0, (LPARAM) wideAppInstallPath.c_str());
			}

			IMalloc * imalloc = 0;
			if (SUCCEEDED(SHGetMalloc(&imalloc)))
			{
				imalloc->Free(pidl);
				imalloc->Release();
			}

		}
	}
Exemple #14
0
void
CPatchDlg::OnSelectDir()
{
    BROWSEINFO info = { 0 };
    info.lpszTitle = _T("Select Patch Directory");
    LPITEMIDLIST pidl = SHBrowseForFolder(&info);
    if(pidl != 0)
    {
        //
        // Get the name of the selected folder.
        //
        TCHAR path[MAX_PATH];
        if(SHGetPathFromIDList(pidl, path))
        {
            _path->SetWindowText(path);
        }

        //
        // Free up memory used.
        //
        IMalloc * imalloc = 0;
        if(SUCCEEDED(SHGetMalloc(&imalloc)))
        {
            imalloc->Free(pidl);
            imalloc->Release();
        }
    }
}
CString CRemotePlaybackDlg::BrowseForFolder(HWND hWnd)
{
	TCHAR szTitle[] = _T("Select a folder");
	TCHAR szDisplayName[MAX_PATH] = _T("");
	TCHAR szPath[MAX_PATH] = _T("");
	BROWSEINFO bi;
	
	bi.hwndOwner= hWnd;
	bi.pidlRoot= NULL;
	bi.lpszTitle= szTitle;
	bi.pszDisplayName = szDisplayName;
	bi.ulFlags= BIF_RETURNONLYFSDIRS;
	bi.lpfn= NULL;
	bi.lParam= 0;
	
	LPITEMIDLIST pItemIDList = SHBrowseForFolder( &bi );
	if( pItemIDList )
	{
		SHGetPathFromIDList(pItemIDList,szPath);
		
		IMalloc *pMalloc;
		if( SHGetMalloc( &pMalloc ) != NOERROR )
		{
			//TRACE( "Failed to get pointer to shells task allocator" ) ;
			return szPath;
		}
		pMalloc->Free( pItemIDList );
		if( pMalloc )
			pMalloc->Release();
	}
	return szPath;
}
KListRef Win32UserWindow::SelectDirectory(
	bool multiple,
	std::string& title,
	std::string& path,
	std::string& defaultName)
{
	KListRef results = new StaticBoundList();

	BROWSEINFO bi = { 0 };
	std::wstring titleW = UTF8ToWide(title);
	bi.lpszTitle = titleW.c_str();
	bi.hwndOwner = this->windowHandle;
	bi.ulFlags = BIF_RETURNONLYFSDIRS;
	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);

	if (pidl != 0)
	{
		wchar_t in_path[MAX_PATH];
		if (SHGetPathFromIDList(pidl, in_path))
		{
			std::wstring inPathW = in_path;
			std::string inPath = WideToUTF8(inPathW);
			results->Append(Value::NewString(inPath));
		}

		IMalloc * imalloc = 0;
		if (SUCCEEDED(SHGetMalloc(&imalloc)))
		{
			imalloc->Free(pidl);
			imalloc->Release();
		}
	}
	return results;
}
Exemple #17
0
string pDialogWindow::folderSelect(Window &parent, const string &path) {
  wchar_t wfilename[PATH_MAX + 1] = L"";
  BROWSEINFO bi;
  bi.hwndOwner = &parent != &Window::None ? parent.p.hwnd : 0;
  bi.pidlRoot = NULL;
  bi.pszDisplayName = wfilename;
  bi.lpszTitle = L"";
  bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
  bi.lpfn = NULL;
  bi.lParam = 0;
  bi.iImage = 0;
  bool result = false;
  LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
  if(pidl) {
    if(SHGetPathFromIDList(pidl, wfilename)) {
      result = true;
      IMalloc *imalloc = 0;
      if(SUCCEEDED(SHGetMalloc(&imalloc))) {
        imalloc->Free(pidl);
        imalloc->Release();
      }
    }
  }
  if(result == false) return "";
  string name = (const char*)utf8_t(wfilename);
  if(name == "") return "";
  name.transform("\\", "/");
  if(name.endswith("/") == false) name.append("/");
  return name;
}
Exemple #18
0
//---------------------------------------------------------------------------
void __fastcall TConfigForm::btnBrowseClick(TObject *Sender)
{
	WCHAR buf[MAX_PATH];
	BROWSEINFOW bi;
	PIDLIST_ABSOLUTE pidl;

	wcscpy_s(buf, MAX_PATH, hAddressBook->Text.c_str());

	bi.hwndOwner = this->Handle;
	bi.pidlRoot = NULL;
	bi.pszDisplayName = buf;
	bi.lpszTitle = _(L"Choose address book location").c_str();
	bi.ulFlags = BIF_EDITBOX;
	bi.lpfn = NULL;
	bi.lParam = NULL;
	bi.iImage = 0;

	CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
	if ((pidl = SHBrowseForFolderW(&bi)) != NULL) {
		if (SHGetPathFromIDListW(pidl, buf))
			hAddressBook->Text = buf;
		IMalloc *pMalloc = NULL;
		SHGetMalloc(&pMalloc);
		pMalloc->Free(pidl);
		pMalloc->Release();
	}
	CoUninitialize();
}
Exemple #19
0
//Pabs inserted
//Parts copied from compiler docs - search for ITEMIDLIST in title in msdn
//Adapted from Q132750:"HOWTO: Convert a File Path to an ITEMIDLIST" in the Knowledge Base
STDAPI PathsEqual(LPCTSTR p0, LPCTSTR p1)
{
	LPSHELLFOLDER pFolder;
	HRESULT hr;
	if (SUCCEEDED(hr = SHGetDesktopFolder(&pFolder)))
	{
		LPITEMIDLIST pidl[2] = { NULL, NULL };
		ULONG chEaten;//only needed by parse dispname
		// Convert the paths to ITEMIDLISTs.
		if (SUCCEEDED(hr = pFolder->ParseDisplayName(NULL, NULL,
				const_cast<LPOLESTR>(&*static_cast<T2W>(p0)), &chEaten, &pidl[0], NULL)) &&
			SUCCEEDED(hr = pFolder->ParseDisplayName(NULL, NULL,
				const_cast<LPOLESTR>(&*static_cast<T2W>(p1)), &chEaten, &pidl[1], NULL)))
		{
			hr = pFolder->CompareIDs(0, pidl[0], pidl[1]);
		}

		//free ITEMIDLISTs
		IMalloc* pm;
		SHGetMalloc(&pm);
		pm->Free(pidl[0]);
		pm->Free(pidl[1]);
		pm->Release();

		pFolder->Release();
	}
	return hr;
}
Exemple #20
0
static BOOL BrowseForFolder(HWND hwnd, const WCHAR *lpszInitialFolder, const WCHAR *lpszCaption, WCHAR *lpszBuf, DWORD dwBufSize)
{
    if (lpszBuf == nullptr || dwBufSize < MAX_PATH)
        return FALSE;

    BROWSEINFO bi = { 0 };
    bi.hwndOwner = hwnd;
    bi.ulFlags   = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
    bi.lpszTitle = lpszCaption;
    bi.lpfn      = BrowseCallbackProc;
    bi.lParam    = (LPARAM)lpszInitialFolder;

    BOOL ok = FALSE;
    LPITEMIDLIST pidlFolder = SHBrowseForFolder(&bi);
    if (pidlFolder) {
        ok = SHGetPathFromIDList(pidlFolder, lpszBuf);

        IMalloc *pMalloc = nullptr;
        if (SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc) {
            pMalloc->Free(pidlFolder);
            pMalloc->Release();
        }
    }

    return ok;
}
BOOL CMyUtils::GetSpecialFolder(int nFolder, TCHAR strFolder[MAX_PATH])
{
	TCHAR	*p = NULL;
	
	LPITEMIDLIST	pidl = NULL;
	IMalloc	*pMalloc = NULL;
	BOOL	bRet = FALSE;
	
	if (SUCCEEDED(SHGetMalloc(&pMalloc)))
	{
		pMalloc->AddRef();
		SHGetSpecialFolderLocation(NULL, nFolder, &pidl);
		
		if (pidl)
        {                      
			bRet = SHGetPathFromIDList(pidl, strFolder);
            // Free the PIDL returned by SHGetSpecialFolderLocation.
           pMalloc->Free(pidl);
        }

        // Release the IMalloc interface.
        pMalloc->Release();
    }

	return bRet;
}
void DirectShowAudioEndpointControl::updateEndpoints()
{
    IMalloc *oleMalloc = 0;
    if (m_deviceEnumerator && CoGetMalloc(1, &oleMalloc) == S_OK) {
        IEnumMoniker *monikers = 0;

        if (m_deviceEnumerator->CreateClassEnumerator(
                CLSID_AudioRendererCategory, &monikers, 0) == S_OK) {
            for (IMoniker *moniker = 0; monikers->Next(1, &moniker, 0) == S_OK; moniker->Release()) {
                OLECHAR *string = 0;
                if (moniker->GetDisplayName(m_bindContext, 0, &string) == S_OK) {
                    QString deviceId = QString::fromWCharArray(string);
                    oleMalloc->Free(string);

                    moniker->AddRef();
                    m_devices.insert(deviceId, moniker);

                    if (m_defaultEndpoint.isEmpty()
                            || deviceId.endsWith(QLatin1String("Default DirectSound Device"))) {
                        m_defaultEndpoint = deviceId;
                    }
                }
            }
            monikers->Release();
        }
        oleMalloc->Release();
    }
}
 std::string BrowseFolder()
{
	TCHAR path[MAX_PATH];

	BROWSEINFO bi = { 0 };
	bi.lpszTitle = ("Please select the folder path...");

	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);

	if (pidl != 0)
	{
		//get the name of the folder and put it in path
		SHGetPathFromIDList(pidl, path);

		//free memory used
		IMalloc * imalloc = 0;
		if (SUCCEEDED(SHGetMalloc(&imalloc)))
		{
			imalloc->Free(pidl);
			imalloc->Release();
		}
		//std::wstring arr_w(path);
		//std::string paths(arr_w.begin(), arr_w.end());
		return path;
	}

	return "";
}
Exemple #24
0
   std::string FileDialogFolder( const std::string &title, const std::string &text ) {

      char path[MAX_PATH];
       BROWSEINFO bi = { 0 };
       bi.lpszTitle = ("All Folders Automatically Recursed.");
       LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );

       if ( pidl != 0 ) {
           // get the name of the folder and put it in path
           SHGetPathFromIDList ( pidl, path );


           // free memory used
           IMalloc * imalloc = 0;
           if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
           {
               imalloc->Free ( pidl );
               imalloc->Release ( );
           }

           return std::string(path);
       }
      
      return ""; 
   }
Exemple #25
0
const char *win_dir_chooser(const char *message, const char *fname)
{
	static char szFileName[MAX_PATH]="";
	BROWSEINFO lpbi;
	LPITEMIDLIST pidl;

	//on vide la structure lpbi
	ZeroMemory(&lpbi,sizeof(BROWSEINFO));

	//on remplit la structure avec des informations utiles
	lpbi.hwndOwner = GET_HWND;
	lpbi.lpszTitle = "Choisissez un répertoire...";
	lpbi.pszDisplayName = szFileName;

	//puis on lance le sélecteur de répertoires.
	pidl = SHBrowseForFolder(&lpbi);

	//si l'utilisateur a sélectionné un fichier
	if(pidl!=0) {
		BOOL result = SHGetPathFromIDList(pidl,szFileName);

		//désallocation de la mémoire déjà utilisée
		IMalloc * imalloc = 0;
		if(SUCCEEDED(SHGetMalloc(&imalloc))) {
			imalloc->Free(pidl);
			imalloc->Release();
		}
		//puis là on retourne le résultat: le chemin absolu
		//du répertoire sélectionné
		if(result) return szFileName;
	}

	return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// Shows a Browse-For-Folder dialog and recursively adds supported files
/// to the playlist. Files are sorted by full filaname before being added.
////////////////////////////////////////////////////////////////////////////////
void AddDirectory()
{
	TCHAR szPath[ MAX_PATH ];
	BROWSEINFO bi = { 0 };
	bi.hwndOwner  = WindowMain;
	bi.pidlRoot   = NULL; // Desktop folder
	bi.lpszTitle  = TEXT( "Please select a directory:" );
	bi.ulFlags    = BIF_VALIDATE | BIF_STATUSTEXT;
	bi.lpfn       = BrowseCallbackProc;

	LPITEMIDLIST pidl = SHBrowseForFolder( &bi );
	if( !pidl ) return;
	
	// Get path
	SHGetPathFromIDList( pidl, szPath );


	// Search
	SearchFolder( szPath );


	// Stay here
	SetCurrentDirectory( szPath );


	// Free memory used
	IMalloc * imalloc = 0;
	if( SUCCEEDED( SHGetMalloc( &imalloc ) ) )
	{
		imalloc->Free( pidl );
		imalloc->Release();
	}
}
static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFOW* aSFI, UINT aInfoFlags)
{
  DWORD shellResult = 0;

  if (!aFile)
    return shellResult;

  PRUnichar fileNativePath[MAX_PATH];
  nsAutoString fileNativePathStr;
  aFile->GetPath(fileNativePathStr);
  ::GetShortPathNameW(fileNativePathStr.get(), fileNativePath, NS_ARRAY_LENGTH(fileNativePath));

  LPITEMIDLIST idList;
  HRESULT hr = ::SHGetSpecialFolderLocation(NULL, aFolder, &idList);
  if (SUCCEEDED(hr)) {
    PRUnichar specialNativePath[MAX_PATH];
    ::SHGetPathFromIDListW(idList, specialNativePath);
    ::GetShortPathNameW(specialNativePath, specialNativePath, NS_ARRAY_LENGTH(specialNativePath));
  
    if (!wcsicmp(fileNativePath, specialNativePath)) {
      aInfoFlags |= (SHGFI_PIDL | SHGFI_SYSICONINDEX);
      shellResult = ::SHGetFileInfoW((LPCWSTR)(LPCITEMIDLIST)idList, 0, aSFI,
                                     sizeof(*aSFI), aInfoFlags);
      IMalloc* pMalloc;
      hr = ::SHGetMalloc(&pMalloc);
      if (SUCCEEDED(hr)) {
        pMalloc->Free(idList);
        pMalloc->Release();
      }
    }
  }
  return shellResult;
}
void choosePath( HWND parent, int hostCtlId )
{
	HWND			hostControl = GetDlgItem( parent, hostCtlId );

	BROWSEINFOW		dialog;
	wchar_t			path[MAX_PATH];    // buffer for file name

	Edit_GetText( hostControl, path, sizeof(path) );

	ZeroMemory(&dialog,sizeof(dialog));

	dialog.lpszTitle		= L"Pick a CA Path";
	dialog.hwndOwner		= parent;
	dialog.pszDisplayName	= path;

	LPITEMIDLIST pidl = SHBrowseForFolder ( &dialog );

	if ( pidl )
	{
		SHGetPathFromIDList ( pidl, path );

		Edit_SetText( hostControl, path );

		IMalloc * imalloc = 0;
		if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
		{
			imalloc->Free ( pidl );
			imalloc->Release ( );
		}
	}
}
Exemple #29
0
void SHMalloc_Free(void * pidl)
{
	IMalloc *pMalloc;
	if (pidl && SUCCEEDED(SHGetMalloc(&pMalloc)))
	{
		pMalloc->Free(pidl);
		pMalloc->Release();
	}
}
Exemple #30
0
// ---------------------------------------------------------------------------
//		よーわからんけど、解放らしい
// ---------------------------------------------------------------------------
static void _SHFree(void *p)
{
    IMalloc *pm;
    SHGetMalloc(&pm);

    if( pm ){
		pm->Free( p );
        pm->Release();
    }
}