Solved

SHBrowseForFolder full example required!

Posted on 2003-12-05
3
738 Views
Last Modified: 2013-11-20
Hi

Can anyone give me a full example of how to use SHBrowseForFolder? To give a complete overview, I want the user to locate their floppy disk drive. Then I check if there's a disk in, if it's formatted and blank, prompting the user to format if otherwise.

Many thanks!
0
Comment
Question by:wjdashwood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9883757
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 9883961
The above sample is the 'fully featured' version. The scoop basically is

    BROWSEINFO      bi;
    LPMALLOC        pMalloc =   NULL;    
    LPITEMIDLIST    pidl;
    char        acSrc   [   MAX_PATH];

    if  (   SHGetMalloc (   &pMalloc)   !=  NOERROR)
            return  (   ( char) 0);

    ZeroMemory  (   &bi,    sizeof  (   BROWSEINFO));

    bi.hwndOwner        =   hWnd;
    bi.pszDisplayName   =   acSrc;
    bi.ulFlags          =   BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS;
    bi.lpszTitle        =   "Please select floppy drive";

    if  (   pidl    =   SHBrowseForFolder   (   &bi))
        {
            if  (   !SHGetPathFromIDList    (   pidl, acSrc))
                    continue;

            // floppy path is now stored in 'acSrc'

            pMalloc->Free   (   pidl);
        }

    if  (   pMalloc)    
            pMalloc->Release();  

And to format a floppy, you could use http://www.codeproject.com/dialog/cformatdrivedialog.asp?target=shformatdrive
0
 

Author Comment

by:wjdashwood
ID: 9884045
Thanks I think I've got the idea.

Cheers
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 169
no14 challenge 14 73
How to convert MFC::CString to UTF8 wchar_t* 10 382
wordmultiple challenge 12 156
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question