コード例 #1
1
ファイル: nppcm.cpp プロジェクト: TodWulff/npp-community
//---------------------------------------------------------------------------
// UnregisterServer
//---------------------------------------------------------------------------
BOOL UnregisterServer(CLSID clsid, LPTSTR lpszTitle) {
  TCHAR szCLSID[GUID_SIZE + 1];
  TCHAR szCLSIDKey[GUID_SIZE + 32];
  TCHAR szKeyTemp[MAX_PATH + GUID_SIZE];
  LPWSTR pwsz;

  StringFromIID(clsid, &pwsz);
  if(pwsz) {
#ifdef UNICODE
    lstrcpy(szCLSID, pwsz);
#else
    WideCharToMultiByte(CP_ACP, 0, pwsz, -1, szCLSID, ARRAYSIZE(szCLSID), NULL, NULL);
#endif
    //free the string
    LPMALLOC pMalloc;
    CoGetMalloc(1, &pMalloc);
    pMalloc->Free(pwsz);
    pMalloc->Release();
  }

  lstrcpy(szCLSIDKey, TEXT("CLSID\\"));
  lstrcat(szCLSIDKey, szCLSID);

  wsprintf(szKeyTemp, TEXT("*\\shellex\\ContextMenuHandlers\\%s"), lpszTitle);
  RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);

  wsprintf(szKeyTemp, TEXT("%s\\%s"), szCLSIDKey, TEXT("InprocServer32"));
  RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
  RegDeleteKey(HKEY_CLASSES_ROOT, szCLSIDKey);

  return TRUE;
}
コード例 #2
0
CString GetOLDDefaultDBName()
{
	CString csDefaultPath;
	LPMALLOC pMalloc;

	if(SUCCEEDED(::SHGetMalloc(&pMalloc))) 
	{ 
		LPITEMIDLIST pidlPrograms;

		SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);

		TCHAR string[MAX_PATH];
		SHGetPathFromIDList(pidlPrograms, string);

		pMalloc->Free(pidlPrograms);
		pMalloc->Release();

		csDefaultPath = string;		
		csDefaultPath += "\\Ditto\\";

		csDefaultPath += "DittoDB.mdb";
	}

	return csDefaultPath;
}
コード例 #3
0
bool CComDialog::PopFolderDlg(OUT char* path, IN char* title, IN BFFCALLBACK cb)
{ 
    BROWSEINFO bi;
	ZeroMemory(&bi, sizeof(BROWSEINFO));    

//初始化入口参数bi开始****************************
    bi.hwndOwner = _hwnd;//::AfxGetMainWnd()->GetSafeHwnd();
    bi.pidlRoot = NULL;
    bi.pszDisplayName = path;//此参数如为NULL则不能显示对话框
    bi.lpszTitle = title;
    bi.ulFlags = 0;
    bi.lpfn = cb;
/*    bi.iImage= IDR_MAINFRAME;*/
//初始化入口参数bi结束*****************************

    LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框
    if (pIDList)
    {
        SHGetPathFromIDList(pIDList, path);
        //取得文件夹路径到Buffer里
		LPMALLOC lpMalloc;
		if (FAILED(SHGetMalloc(&lpMalloc))) 
			return false;
		//释放内存
		lpMalloc->Free(pIDList);
		lpMalloc->Release();

		return true;
    }
	else
	{
		return false;
	}
}
コード例 #4
0
//----------------------------------------------------------------------------------------
static void GetWindowsFolder(int folder, nsFileSpec& outDirectory)
//----------------------------------------------------------------------------------------
{

    if (gGetSpecialPathProc) {
        TCHAR path[MAX_PATH];
        HRESULT result = gGetSpecialPathProc(NULL, path, folder, true);
        
        if (!SUCCEEDED(result)) 
            return;

        // Append the trailing slash
        int len = PL_strlen(path);
        if (len>1 && path[len-1] != '\\') 
        {
            path[len]   = '\\';
            path[len + 1] = '\0';
        }
        outDirectory = path;
        return;
    }

    LPMALLOC pMalloc = NULL;
    LPSTR pBuffer = NULL;
    LPITEMIDLIST pItemIDList = NULL;
    int len;
 
    // Get the shell's allocator. 
    if (!SUCCEEDED(SHGetMalloc(&pMalloc))) 
        return;

    // Allocate a buffer
    if ((pBuffer = (LPSTR) pMalloc->Alloc(MAX_PATH + 2)) == NULL) 
        return; 
 
    // Get the PIDL for the folder. 
    if (!SUCCEEDED(SHGetSpecialFolderLocation( 
            NULL, folder, &pItemIDList)))
        goto Clean;
 
    if (!SUCCEEDED(SHGetPathFromIDList(pItemIDList, pBuffer)))
        goto Clean;

    // Append the trailing slash
    len = PL_strlen(pBuffer);
    pBuffer[len]   = '\\';
    pBuffer[len + 1] = '\0';

    // Assign the directory
    outDirectory = pBuffer;

Clean:
    // Clean up. 
    if (pItemIDList)
        pMalloc->Free(pItemIDList); 
    if (pBuffer)
        pMalloc->Free(pBuffer); 

	pMalloc->Release();
} // GetWindowsFolder
コード例 #5
0
bool plBrowseFolder::GetFolder(char *path, const char *startPath, const char *title, HWND hwndOwner)
{
    BROWSEINFO bi;
    memset(&bi, 0, sizeof(bi));
    bi.hwndOwner    = hwndOwner;
    bi.lpszTitle    = title;
    bi.lpfn         = BrowseCallbackProc;
    bi.lParam       = (LPARAM) startPath;

    ITEMIDLIST *iil = SHBrowseForFolder(&bi);
    // Browse failed, or cancel was selected
    if (!iil)
        return false;
    // Browse succeded.  Get the path.
    else
        SHGetPathFromIDList(iil, path);

    // Free the memory allocated by SHBrowseForFolder
    LPMALLOC pMalloc;
    SHGetMalloc(&pMalloc);
    pMalloc->Free(iil);
    pMalloc->Release();

    return true;
}
コード例 #6
0
ファイル: misc.cpp プロジェクト: akavel/wed-editor
 BOOL	GetSpecialFolder(UINT SpecialFolder, CString &SpecialFolderString)

{
	HRESULT hr;

	LPITEMIDLIST pidl;

	hr = SHGetSpecialFolderLocation(NULL, SpecialFolder, &pidl);

    if(SUCCEEDED(hr))
		{
		// Convert the item ID list's binary representation into a file system path
		char szPath[_MAX_PATH];

		if(SHGetPathFromIDList(pidl, szPath))
			{
			// Allocate a pointer to an IMalloc interface
			LPMALLOC pMalloc;

			// Get the address of our task allocator's IMalloc interface
			hr = SHGetMalloc(&pMalloc);

			// Free the item ID list allocated by SHGetSpecialFolderLocation
			pMalloc->Free(pidl);

			// Free our task allocator
			pMalloc->Release();

			// Work with the special folder's path (contained in szPath)
			SpecialFolderString = szPath;	SpecialFolderString += "\\";
			return TRUE;
			}
		}
	return FALSE;
}
コード例 #7
0
ファイル: shell.cpp プロジェクト: beru/sakura
/*!	特殊フォルダのパスを取得する
	SHGetSpecialFolderPath API(shell32.dll version 4.71以上が必要)と同等の処理をする

	@param [in] nFolder CSIDL (constant special item ID list)
	@param [out] pszPath 特殊フォルダのパス

	@author ryoji
	@date 2007.05.19 新規
	@date 2017.06.24 novice SHGetFolderLocation()に変更

	@note SHGetFolderLocation()は、shell32.dll version 5.00以上が必要
*/
BOOL GetSpecialFolderPath( int nFolder, LPTSTR pszPath )
{
	BOOL bRet = FALSE;
	HRESULT hres;
	LPITEMIDLIST pidl = NULL;

#if (WINVER >= _WIN32_WINNT_WIN2K)
	hres = ::SHGetFolderLocation( NULL, nFolder, NULL, 0, &pidl );
	if( SUCCEEDED( hres ) ){
		bRet = ::SHGetPathFromIDList( pidl, pszPath );
		::CoTaskMemFree( pidl );
	}
#else
	LPMALLOC pMalloc;

	hres = ::SHGetMalloc( &pMalloc );
	if( FAILED( hres ) )
		return FALSE;

	hres = ::SHGetSpecialFolderLocation( NULL, nFolder, &pidl );
	if( SUCCEEDED( hres ) ){
		bRet = ::SHGetPathFromIDList( pidl, pszPath );
		pMalloc->Free( (void*)pidl );
	}

	pMalloc->Release();
#endif

	return bRet;
}
コード例 #8
0
int CFolderDialog::DoModal()
{
	int nReturn = IDOK;

	// initialize the result to the starting folder value
	m_strFinalFolderName = m_strInitialFolderName;

	ITEMIDLIST* piid = NULL;

	// call the shell function
	piid = ::SHBrowseForFolder(&m_bi);

	// process the result
	if (piid && ::SHGetPathFromIDList(piid, m_szPath)) {
		m_strFinalFolderName = m_szPath;
		nReturn = IDOK;
	} else {
		nReturn = IDCANCEL;
	}

	// Release the ITEMIDLIST if we got one
	if (piid) {
		LPMALLOC lpMalloc;
		VERIFY(::SHGetMalloc(&lpMalloc) == NOERROR);
		lpMalloc->Free(piid);
		lpMalloc->Release();
	}

	return nReturn;
}
コード例 #9
0
ファイル: Util.cpp プロジェクト: zhangbo7364/winutil
BOOL Util::SelectFolder(HWND hWnd, LPSTR lpszFolder, LPCSTR lpszTitle,
		UINT ulFlag) {
	BROWSEINFO bi;
	ITEMIDLIST *pidl;

	memset(&bi, 0, sizeof(bi));

	bi.hwndOwner = hWnd;
	bi.pidlRoot = NULL;
	bi.pszDisplayName = lpszFolder;
	bi.lpszTitle = lpszTitle;
//	bi.ulFlags = BIF_RETURNONLYFSDIRS;BIF_NEWDIALOGSTYLE
	bi.ulFlags = ulFlag;
	bi.lpfn = NULL;
	bi.lParam = 0;
	bi.iImage = 0;

	pidl = SHBrowseForFolder(&bi);

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

		LPMALLOC lpMalloc;

		if (SUCCEEDED(SHGetMalloc(&lpMalloc))) {
			lpMalloc->Free(pidl);
			lpMalloc->Release();
		}

		return TRUE;
	}

	return FALSE;
}
コード例 #10
0
ファイル: plBrowseFolder.cpp プロジェクト: H-uru/Plasma
plFileName plBrowseFolder::GetFolder(const plFileName &startPath, const ST::string &title, HWND hwndOwner)
{
    BROWSEINFOW bi;
    memset(&bi, 0, sizeof(bi));
    ST::wchar_buffer titleW = title.to_wchar();
    ST::wchar_buffer startPathW = startPath.WideString();
    bi.hwndOwner    = hwndOwner;
    bi.lpszTitle    = titleW.data();
    bi.lpfn         = BrowseCallbackProc;
    bi.lParam       = (LPARAM) startPathW.data();

    LPITEMIDLIST iil = SHBrowseForFolderW(&bi);
    plFileName path;
    if (!iil) {
        // Browse failed, or cancel was selected
        path = ST::null;
    } else {
        // Browse succeded.  Get the path.
        wchar_t buffer[MAX_PATH];
        SHGetPathFromIDListW(iil, buffer);
        path = ST::string::from_wchar(buffer);
    }

    // Free the memory allocated by SHBrowseForFolder
    LPMALLOC pMalloc;
    SHGetMalloc(&pMalloc);
    pMalloc->Free(iil);
    pMalloc->Release();

    return path;
}
コード例 #11
0
ファイル: OptHTTP.cpp プロジェクト: DmitrySigaev/DSMedia
void COptHTTP::OnBrowseCache() 
{
	BROWSEINFO brw;
	LPMALLOC pMalloc;
	LPITEMIDLIST ret;
	char dir[MAX_PATH];

	if (NOERROR == ::SHGetMalloc(&pMalloc) ) {

		m_CacheDir.GetWindowText(szCacheDir, MAX_PATH);

		memset(&brw, 0, sizeof(BROWSEINFO));
		brw.hwndOwner = this->GetSafeHwnd();
		brw.pszDisplayName = dir;
		brw.lpszTitle = "Select HTTP Cache Directory...";
		brw.ulFlags = 0L;
		brw.lpfn = LocCbck;

		ret = SHBrowseForFolder(&brw);
		if (ret != NULL) {
			if (::SHGetPathFromIDList(ret, dir)) {
				m_CacheDir.SetWindowText(dir);
			}
			pMalloc->Free(ret);
		}
		pMalloc->Release();
	}
}
コード例 #12
0
ファイル: Page1.cpp プロジェクト: ssnian/IESafe
void CPage1::OnBnClickedButton8()
{
	// TODO: 在此添加控件通知处理程序代码
	BROWSEINFO bi;
    WCHAR Buffer[MAX_PATH];
    //初始化入口参数bi开始
    bi.hwndOwner = NULL;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框
    bi.lpszTitle = L"请选择文件夹";
    bi.ulFlags = 0;
    bi.lpfn = NULL;
    //初始化入口参数bi结束
    LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框
	bool hadGet = false;
    if(pIDList)
	{
		hadGet = (bool)SHGetPathFromIDList(pIDList,Buffer);
       //取得文件夹路径到Buffer里
     // m_ctrbrowse.SetWindowText(Buffer);//将路径保存在一个CString对象里
	}
	//MessageBox((LPCTSTR)Buffer, L"f");
	if(hadGet)
		GetDlgItem(IDC_EDIT3)->SetWindowTextW(Buffer);
    LPMALLOC lpMalloc;
    if(FAILED(SHGetMalloc(&lpMalloc))) return;
    //释放内存
    lpMalloc->Free(pIDList);
    lpMalloc->Release();
}
コード例 #13
0
ファイル: LocalTreeView.cpp プロジェクト: idgaf/FileZilla3
wxString CLocalTreeView::GetSpecialFolder(int folder, int &iconIndex, int &openIconIndex)
{
	LPITEMIDLIST list;
	if (SHGetSpecialFolderLocation((HWND)GetHandle(), folder, &list) != S_OK)
		return _T("");

	SHFILEINFO shFinfo;
	if (!SHGetFileInfo((LPCTSTR)list, 0, &shFinfo, sizeof(shFinfo), SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON))
		return _T("");

	DestroyIcon(shFinfo.hIcon);
	iconIndex = shFinfo.iIcon;

	if (!SHGetFileInfo((LPCTSTR)list, 0, &shFinfo, sizeof(shFinfo), SHGFI_PIDL | SHGFI_ICON | SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_DISPLAYNAME))
		return _T("");

	DestroyIcon(shFinfo.hIcon);
	openIconIndex = shFinfo.iIcon;

	wxString name = shFinfo.szDisplayName;

	LPMALLOC pMalloc;
    SHGetMalloc(&pMalloc);

	if (pMalloc)
	{
		pMalloc->Free(list);
		pMalloc->Release();
	}
	else
		wxLogLastError(wxT("SHGetMalloc"));

	return name;
}
コード例 #14
0
ファイル: SoliDire.cpp プロジェクト: jokerlee/college
BOOL CSoliDire::add_folder()
{	
	BROWSEINFO bi;
    ZeroMemory(&bi,sizeof(BROWSEINFO));
    LPMALLOC pMalloc;
    LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
    TCHAR * pth = new TCHAR[MAX_PATH];
    if(pidl != NULL)
    {
        SHGetPathFromIDList(pidl,pth);
        if(SUCCEEDED(SHGetMalloc(&pMalloc)))//pidl指向的对象用完应该释放,之前忽略了
        {
            pMalloc->Free(pidl);
            pMalloc->Release();
        }
		CString path(pth);
		if (path != "")
		{
			build_dir_tree(path);
			SetModifiedFlag(TRUE);
			printf("Folder %s successfully added.\n", path);
			return TRUE;
		}
    }
	return FALSE;
}
コード例 #15
0
ファイル: FolderDialog.cpp プロジェクト: Casidi/ExtractData
BOOL CFolderDialog::DoModal(HWND hWnd, LPCTSTR lpszTitle, LPTSTR pDir)
{
	BROWSEINFO bi = {};
	bi.hwndOwner = hWnd;
	bi.lpfn = reinterpret_cast<BFFCALLBACK>(BrowseCallBackProc);
	bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
	bi.lParam = reinterpret_cast<LPARAM>(pDir);
	bi.lpszTitle = lpszTitle;

	LPITEMIDLIST pItemID = SHBrowseForFolder(&bi);
	if (pItemID == nullptr)
		return FALSE;

	LPMALLOC pMalloc = nullptr;
	if (SHGetMalloc(&pMalloc) == E_FAIL)
	{
		CError error;
		error.Message(hWnd, _T("SHGetMalloc Error"));
		return FALSE;
	}

	SHGetPathFromIDList(pItemID, pDir);

	pMalloc->Free(pItemID);
	pMalloc->Release();

	return TRUE;
}
コード例 #16
0
std::string DirectorySelectDlg( HWND hParent, const TCHAR* title,  const TCHAR* old )
{

	std::string result;

	LPMALLOC pMalloc;
	if( ::SHGetMalloc( &pMalloc ) == NOERROR )
	{
		BROWSEINFO bi = {0};

		bi.hwndOwner = hParent;
		bi.lpszTitle = title;
		bi.ulFlags = 0;
		bi.lpfn = DirectorySelect_Callback;
		bi.lParam = ( LPARAM )old;

		TCHAR pszBuffer[MAX_PATH];
		if( LPITEMIDLIST pidl =::SHBrowseForFolder( &bi ) )
		{
			if( ::SHGetPathFromIDList( pidl, pszBuffer ) )
			{
				result = pszBuffer;
			}
			pMalloc->Free( pidl );
		}
		pMalloc->Release();
	}
	return result;
}
コード例 #17
0
/* #FN#
   Responds to TVN_DELETEITEM message in order to release the memory
   allocated by the shell folders */
void
/* #AS#
   Nothing */
CShellTree::
OnDeleteShellItem(
	NMHDR   *pNMHDR, /* #IN# */
	LRESULT *pResult /* #OUT# */
)
{
	LPTVITEMDATA lptvid   = NULL;
	LPMALLOC     lpMalloc = NULL;
	HRESULT      hr;

	NM_TREEVIEW *pNMTreeView = (NM_TREEVIEW *)pNMHDR;

	/* Let's free the memory for the TreeView item data */
	hr = SHGetMalloc( &lpMalloc );
	if( FAILED(hr) )
		return;

	lptvid = (LPTVITEMDATA)pNMTreeView->itemOld.lParam;
	lptvid->lpsfParent->Release();
	lpMalloc->Free( lptvid->lpi );
	lpMalloc->Free( lptvid->lpifq );
	lpMalloc->Free( lptvid );
	lpMalloc->Release();

} /* #OF# CShellTree::OnDeleteShellItem */
コード例 #18
0
bool CBrowseForFolder::SelectFolder()
{
	bool bRet = false;

	LPITEMIDLIST pidl;
	if ((pidl = ::SHBrowseForFolder(&m_bi)) != NULL)
	{
		m_strPath.Empty();
		if (::SHGetPathFromIDList(pidl, m_szSelected))
		{
			bRet = true;
			m_strPath = m_szSelected;
		}

		LPMALLOC pMalloc;
		//Retrieve a pointer to the shell's IMalloc interface
		if (SUCCEEDED(SHGetMalloc(&pMalloc)))
		{
			// free the PIDL that SHBrowseForFolder returned to us.
			pMalloc->Free(pidl);
			// release the shell's IMalloc interface
			(void)pMalloc->Release();
		}
	}
	m_hwnd = NULL;

	return bRet;
}
コード例 #19
0
void CBitTorrentSettingsPage::OnTorrentsBrowse() 
{
	TCHAR szPath[MAX_PATH];
	LPITEMIDLIST pPath;
	LPMALLOC pMalloc;
	BROWSEINFO pBI;
		
	ZeroMemory( &pBI, sizeof(pBI) );
	pBI.hwndOwner		= AfxGetMainWnd()->GetSafeHwnd();
	pBI.pszDisplayName	= szPath;
	pBI.lpszTitle		= _T("Select folder for torrents:");
	pBI.ulFlags			= BIF_RETURNONLYFSDIRS;
	
	pPath = SHBrowseForFolder( &pBI );

	if ( pPath == NULL ) return;

	SHGetPathFromIDList( pPath, szPath );
	SHGetMalloc( &pMalloc );
	pMalloc->Free( pPath );
	pMalloc->Release();
	
	UpdateData( TRUE );
	m_sTorrentPath = szPath;
	UpdateData( FALSE );
}
コード例 #20
0
ファイル: FilePro.cpp プロジェクト: cugxiangzhenwei/MySrcCode
CString CFilePro::GetSelectedFolder()
{
	BROWSEINFO bi;  
	ZeroMemory(&bi,sizeof(BROWSEINFO));  
	LPMALLOC pMalloc;  
	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);  

	if(!pidl )
	{
		m_strErrMsg = "用户取消";
		return "";
	}

	CString strFolderOut = "";
	TCHAR * path = new TCHAR[MAX_PATH];   

	SHGetPathFromIDList(pidl,path);  
	if(SUCCEEDED(SHGetMalloc(&pMalloc))) 
	{  
		pMalloc->Free(pidl);  
		pMalloc->Release();  
	}

	strFolderOut = path;
	delete [] path;
	return strFolderOut;
}
コード例 #21
0
// only one full qualified PIDL has been passed
void CShellContextMenu::SetObjects(LPITEMIDLIST pidl)
{
	// free all allocated datas
	if (m_psfFolder && bDelete)
		m_psfFolder->Release ();
	m_psfFolder = NULL;
	FreePIDLArray (m_pidlArray);
	m_pidlArray = NULL;

		// full qualified PIDL is passed so we need
	// its parent IShellFolder interface and its relative PIDL to that
	LPITEMIDLIST pidlItem = NULL;
	SHBindToParent ((LPCITEMIDLIST) pidl, IID_IShellFolder, (void **) &m_psfFolder, (LPCITEMIDLIST *) &pidlItem);	

	m_pidlArray = (LPITEMIDLIST *) malloc (sizeof (LPITEMIDLIST));	// allocate ony for one elemnt
	m_pidlArray[0] = CopyPIDL (pidlItem);


	// now free pidlItem via IMalloc interface (but not m_psfFolder, that we need later
	LPMALLOC lpMalloc = NULL;
	SHGetMalloc (&lpMalloc);
	lpMalloc->Free (pidlItem);
	lpMalloc->Release();

	nItems = 1;
	bDelete = TRUE;	// indicates that m_psfFolder should be deleted by CShellContextMenu
}
コード例 #22
0
CString Directories::browseForDir(CString title)
{
  static char buffer[1024];
  LPMALLOC pMalloc;
  LPITEMIDLIST pidl;
  
  CString res;
  
  if(SUCCEEDED(SHGetMalloc(&pMalloc))) {
    BROWSEINFO bi;
    ZeroMemory(&bi, sizeof(bi));
    bi.hwndOwner = m_hWnd;
    bi.lpszTitle = title;
    bi.pidlRoot = 0;
    bi.ulFlags = BIF_RETURNONLYFSDIRS;
    bi.lpfn = browseCallbackProc;
    bi.lParam = (LPARAM)(LPCTSTR)initialFolderDir;
    
    pidl = SHBrowseForFolder(&bi);
    
    if(pidl) {
      if(SHGetPathFromIDList(pidl, buffer)) {
        res = buffer;
      }
      pMalloc->Free(pidl);
      pMalloc->Release();
    }
  }
  return res;
}
コード例 #23
0
void SetCertDirDlg::OnBnClickedButton1()
{
	LPMALLOC pMalloc;
    
    if( SUCCEEDED( SHGetMalloc( &pMalloc ) ) ) 
    {
        TCHAR szTitle[] = _T("Choose Directory for storing certificates.");
        BROWSEINFO bi;
        ZeroMemory( &bi, sizeof( bi ) );
        bi.hwndOwner = NULL;
        bi.pszDisplayName = NULL;
        bi.lpszTitle = szTitle;
        bi.pidlRoot = NULL;
		bi.ulFlags = BIF_RETURNONLYFSDIRS;
        
        LPITEMIDLIST pidl = SHBrowseForFolder( &bi );
        if( pidl ) 
        {
            TCHAR szDir[MAX_PATH];
            if( SHGetPathFromIDList( pidl, szDir ) ) 
            {
				m_CertificatePath.SetWindowText(szDir);
				m_CertificatePath.SetFocus();
            }
            pMalloc->Free(pidl); 
            pMalloc->Release();
        }
    }
}
コード例 #24
0
ファイル: Playlist.cpp プロジェクト: Bevara/Access
void Playlist::AddDir(Bool do_recurse)
{
	BROWSEINFO brw;
	LPMALLOC pMalloc;
	LPITEMIDLIST ret;
	char dir[MAX_PATH];

	Bool res = GF_FALSE;
	if (NOERROR == ::SHGetMalloc(&pMalloc) ) {
		memset(&brw, 0, sizeof(BROWSEINFO));
		brw.hwndOwner = this->GetSafeHwnd();
		brw.pszDisplayName = dir;
		brw.lpszTitle = "Select Directory...";
		brw.ulFlags = 0L;
		brw.lpfn = LocCbck;

		ret = SHBrowseForFolder(&brw);
		if (ret != NULL) {
			if (::SHGetPathFromIDList(ret, dir)) res = GF_TRUE;
			pMalloc->Free(ret);
		}
		pMalloc->Release();
	}
	if (!res) return;
	strcpy(szCacheDir, dir);

	gf_enum_directory(dir, GF_FALSE, pl_enum_dir_item, this, NULL);
	if (do_recurse) gf_enum_directory(dir, GF_FALSE, pl_enum_dir_dirs, this, NULL);
	m_all_dead_entries=-1;
	RefreshList();
}
コード例 #25
0
ファイル: csalerts_sdl.cpp プロジェクト: blezek/marathon-ios
bool system_alert_choose_scenario(char *chosen_dir)
{
#if defined(__WIN32__)
	BROWSEINFO bi = { 0 };
	TCHAR path[MAX_PATH];
	bi.lpszTitle = _T("Select a scenario to play:");
	bi.pszDisplayName = path;
	bi.lpfn = browse_callback_proc;
	bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | 0x00000200; // no "New Folder" button
	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
	if (pidl)
	{
		SHGetPathFromIDList(pidl, path);
#ifdef UNICODE
		WideCharToMultiByte(CP_UTF8, 0, path, -1, chosen_dir, 256, NULL, NULL);
#else
		strncpy(chosen_dir, path, 255);
#endif
		LPMALLOC pMalloc = NULL;
		SHGetMalloc(&pMalloc);
		pMalloc->Free(pidl);
		pMalloc->Release();
		return true;
	}
#endif
	return false;
}
コード例 #26
0
ファイル: WndUtils.cpp プロジェクト: FlynnShek/facerecog
bool SelDirectory ( HWND hWnd, LPCTSTR strTitle, CString &strDir )  
{  
	BROWSEINFO bi;  
	char szDisplayName[MAX_PATH] = {0};  

	bi.hwndOwner = hWnd;  
	bi.pidlRoot = NULL;  
	bi.pszDisplayName = szDisplayName;  
	bi.lpszTitle = strTitle;  
	bi.ulFlags = 0;  
	bi.lpfn = BrowserCallbackProc;  
	bi.lParam = (LPARAM)(LPCTSTR)strDir;  
	bi.iImage = NULL;  

	// 显示目录选择对话框,如果按了取消,那么piid为NULL  
	ITEMIDLIST* piid = ::SHBrowseForFolder ( &bi );  

	if ( piid == NULL )  return false;  

	// 得到选择的目录  
	BOOL bValidPath = ::SHGetPathFromIDList ( piid, szDisplayName );  
	if ( ! bValidPath ) return false;  

	LPMALLOC lpMalloc;  
	HRESULT hr = ::SHGetMalloc ( &lpMalloc );
	assert(hr == NOERROR);  
	lpMalloc->Free ( piid );  
	lpMalloc->Release ();  

	if ( szDisplayName[0] == '\0' ) return false; //用户选择的可能的虚拟文件系统  

	strDir = szDisplayName;  

	return true;
}
コード例 #27
0
ファイル: ConfigFile.cpp プロジェクト: dalinhuang/demodemo
void CConfigFile::OnBtnFolder() 
{
	// TODO: Add your control notification handler code here
	//Open file folder dialogue box
	LPMALLOC   pMalloc;  
	if   (::SHGetMalloc(&pMalloc)   ==   NOERROR)   
	{   
		BROWSEINFO   bi;   
		TCHAR   pszBuffer[MAX_PATH];   
		LPITEMIDLIST   pidl;   
		bi.hwndOwner   =   this->m_hWnd;   
		bi.pidlRoot   =   NULL;   
		bi.pszDisplayName   =   pszBuffer;   
		bi.lpszTitle   =   _T(ConvertString("select folder"));   
		bi.ulFlags   =   BIF_RETURNFSANCESTORS   |   BIF_RETURNONLYFSDIRS;   
		bi.lpfn   =   NULL;   
		bi.lParam   =   0;   
		bi.iImage   =   0;   
		if   ((pidl   =   ::SHBrowseForFolder(&bi))   !=   NULL)   
		{   
			if   (::SHGetPathFromIDList(pidl,   pszBuffer))   
			{
				m_CSFile.Empty();
				m_CSFile  =  pszBuffer;  
				SetDlgItemText(IDC_EDIT_EXPORT, pszBuffer);
			}
			else
			{
				return;   
			}
			pMalloc->Free(pidl);   
		}   
		pMalloc->Release();   
	} 
}
コード例 #28
0
ファイル: Prefers.cpp プロジェクト: Chuvi-w/cpp-labs
//------------------------------------------------------------------------------
void __fastcall TPrefsForm::BrowseButtonClick(TObject* Sender) {
  BROWSEINFO    info;
  char          szDir[MAX_PATH];
  char          szDisplayName[MAX_PATH];
  LPITEMIDLIST  pidl;
  LPMALLOC      pShellMalloc;

  if(SHGetMalloc(&pShellMalloc) == NO_ERROR) {
    memset(&info, 0x00, sizeof(info));
    info.hwndOwner = Handle;
    info.pidlRoot  = 0;
    info.pszDisplayName = szDisplayName;
    info.lpszTitle = LMessagesOpt.SelectFolder;
    info.ulFlags = BIF_NEWDIALOGSTYLE; //BIF_RETURNONLYFSDIRS;
    info.lpfn = 0;
    pidl = SHBrowseForFolder(&info);

    if(pidl) {
      if(SHGetPathFromIDList(pidl, szDir))
        BackupPath->Text = szDir;

      pShellMalloc->Free(pidl);
    }

    pShellMalloc->Release();
  }
}
コード例 #29
0
ファイル: kdecm.cpp プロジェクト: KDE/kde-runtime
//---------------------------------------------------------------------------
// UnregisterServer
//---------------------------------------------------------------------------
BOOL UnregisterServer(CLSID clsid, LPTSTR lpszTitle)
{
/*!
 * This function removes the keys from registry
 * NOTE: we can do this better with Qt
 */

    TCHAR szCLSID[GUID_SIZE + 1];
    TCHAR szCLSIDKey[GUID_SIZE + 32];
    TCHAR szKeyTemp[MAX_PATH + GUID_SIZE];
    LPTSTR pwsz;

    StringFromIID(clsid, &pwsz);
    if(pwsz) {
        lstrcpy(szCLSID, pwsz);
        //free the string
        LPMALLOC pMalloc;
        CoGetMalloc(1, &pMalloc);
        pMalloc->Free(pwsz);
        pMalloc->Release();
    }

    lstrcpy(szCLSIDKey, TEXT("CLSID\\"));
    lstrcat(szCLSIDKey, szCLSID);

    wsprintf(szKeyTemp, TEXT("*\\shellex\\ContextMenuHandlers\\%s"), lpszTitle);
    RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);

    wsprintf(szKeyTemp, TEXT("%s\\%s"), szCLSIDKey, TEXT("InprocServer32"));
    RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
    RegDeleteKey(HKEY_CLASSES_ROOT, szCLSIDKey);

    return TRUE;
}
コード例 #30
0
ファイル: contactinfo.cpp プロジェクト: Seldom/miranda-ng
int BrowseForFolder(HWND hwnd, char *szPath)
{
	int result = 0;
	LPMALLOC pMalloc;

	if (SUCCEEDED(CoGetMalloc(1, &pMalloc))) {
		ptrT tszPath(mir_a2t(szPath));
		BROWSEINFO bi = { 0 };
		bi.hwndOwner = hwnd;
		bi.pszDisplayName = tszPath;
		bi.lpszTitle = TranslateT("Select Folder");
		bi.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS;				// Use this combo instead of BIF_USENEWUI
		bi.lParam = (LPARAM)szPath;

		ITEMIDLIST *pidlResult = SHBrowseForFolder(&bi);
		if (pidlResult) {
			SHGetPathFromIDListA(pidlResult, szPath);
			mir_strcat(szPath, "\\");
			result = 1;
		}
		pMalloc->Free(pidlResult);
		pMalloc->Release();
	}

	return result;
}