Solved

Using DlgDirList function

Posted on 2000-02-29
6
567 Views
Last Modified: 2012-08-14
I am trying to use the DlgDirList function which fills the specified list box
with the names of all files matching the specified path or filename. How do you use it I have tried and I can not get it to work.  I want the list box to list the contents of a specified directory, is this possible.

Thanks
Richard
0
Comment
Question by:Richard_Eustace
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
Wyn earned 100 total points
ID: 2569220
For Example:

DlgDirList(hWnd, "*.exe", LISTEXE, PATH, DDL_DIRECTORY | DDL_DRIVES);

This would list all .exe files to the ListBox named LISTEXE with the static path being PATH.  It will also list the directories and drives.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2569234
FYI ,here is description of that API:

The DlgDirList function fills the specified list box with the names of all files matching the specified path or filename.

int DlgDirList( HWND hDlg,
 // handle to dialog box with list box
 
LPTSTR lpPathSpec,
 // pointer to path or filename string
 
int nIDListBox,
 // identifier of list box
 
int nIDStaticPath,
 // identifier of static control
 
UINT uFileType
 // file attributes to display
 
);
   


Parameters
hDlg

Identifies the dialog box that contains the list box.

lpPathSpec

Points to a null-terminated string that contains the path or filename. DlgDirList modifies this string, which should be long enough to contain the modifications. For more information about this parameter, see the Remarks section.

nIDListBox

Specifies the identifier of a list box. If this parameter is zero, DlgDirList assumes that no list box exists and does not attempt to fill one.

nIDStaticPath

Specifies the identifier of the static control used for displaying the current drive and directory. If this parameter is zero, DlgDirList assumes that no such control is present.

uFileType

Specifies attributes of the filenames to be displayed. This parameter must be one or more of the following values: Value
 Description
 
DDL_ARCHIVE
 Includes archived files.
 
DDL_DIRECTORY
 Includes subdirectories. Subdirectory names are enclosed in square brackets ([ ]).
 
DDL_DRIVES
 Includes drives. Drives are listed in the form [-x-], where x is the drive letter.
 
DDL_EXCLUSIVE
 Includes only files with the specified attributes. By default, read-write files are listed even if DDL_READWRITE is not specified.
 
DDL_HIDDEN
 Includes hidden files.
 
DDL_READONLY
 Includes read-only files.
 
DDL_READWRITE
 Includes read-write files with no additional attributes.
 
DDL_SYSTEM
 Includes system files.
 
DDL_POSTMSGS
 Posts messages to the application¡¯s message queue. By default, DlgDirList sends messages directly to the dialog box procedure.
 


Return Values
If a listing is made ¾ even an empty listing ¾ the return value is nonzero. If the input string does not contain a valid search path, the return value is zero.

Remarks
If you specify a zero-length string for the lpPathSpec parameter or if you specify only a directory name with no filename, the string will be changed to *.*

The lpPathSpec parameter has the following form:

[drive:] [[\u]directory[\idirectory]\u] [filename]

In this example, drive is a drive letter, directory is a valid directory name, and filename is a valid filename that must contain at least one wildcard (? or *).

If lpPathSpec includes a drive or directory name, or both, the current drive and directory are changed to the specified drive and directory before the list box is filled. The static control identified by the nIDStaticPath parameter is also updated with the new drive or directory name, or both.

After the list box is filled, DlgDirList updates lpPathSpec by removing the drive or directory portion, or both, of the path and filename.

DlgDirList sends the LB_RESETCONTENT and LB_DIR messages to the list box.  
 
 
Free to ask.
Regards
W.Yinan  
 
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2569262
Btw: the *.exe is simply an example.You can specify your path and filename.Plz consult the description above.
If problem exists,A-S-K
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Expert Comment

by:ecbakke
ID: 3959319
This first parm hWnd isn't needed when using MFC...I haven't been able to get the function to work using the wrapper in MFC...anybody have samle code where a listbox in a dialog can be filled with Drives/directories/files on NT4.0?
0
 

Expert Comment

by:ecbakke
ID: 3959325
I forgot to specify I'm using MFC 6.0 using VC++ 6.0
0
 

Expert Comment

by:ecbakke
ID: 3982162
I got it to work using MFC...here's the code:

char szPath [MAX_PATH] = {"c:\\"} // sets a string array of maximum path length to starting path

int nResult = DlgDirListComboBox (szPath,IDC_COMBOBOX1,IDC_STATICPATH,DDL_DRIVES | DDL_DIRECTORY); // loads combo box with drives and directories
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

777 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