I'm having trouble using the DlgDirList() function to list files in a list-box.
I don't understand how to use the lpPathSpec parameter.
If you have any info, your reply will be much appreciated.
Thanx!
I'm having trouble using the DlgDirList() function to list files in a list-box.
I don't understand how to use the lpPathSpec parameter.
If you have any info, your reply will be much appreciated.
Thanx!
Red hat avatar on the Windows board...pah.....
Anyway
That param acts as a search criteria for the listing process and it acts in conjuction with the last param, a DWORD stating what file type ...for example...assuming the last param is
"C:\" - will show all files in the root directoryCode:DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | DDL_ARCHIVE;
"C:\temp" - will show all files in the temp directory
"C:\*.log" - will how all files in the root dir that end with an extension of .log....
Doesn't work.
At the moment i am using SetCurrentDirectory to set the dir,
then by using GetCurrentDirectory(), i pass the buffer to DlgDirList() and it works.
Do you perhaps know how i can list the sub-directories without the square braces at the beggining and end?
OK....just a test....but are you including the "C:\WhateverDrive" in code, or are you entering it from an edit or whatever at runtime?
If in code, dont forget the extra escape char....ala
"C:\\WhateverDrive"
Before answering the first time I did take 5 minutes to create an example ( I hadnt used this func before....)
Here's part of my code.....its in MFC & its rushed (Hell 40 mins between our posts and I made a cup of tea while doing it!!)....but it should give an idea of how this function can work...
Code:void CMyDialog::OnOK() { CString str; DWORD dwStyle = DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | DDL_ARCHIVE; GetDlgItemText(IDC_EDIT1,str); if(:: DlgDirList(m_hWnd,str.GetBuffer(0), IDC_LIST1,IDC_STATIC1,dwStyle) == 0) MessageBox(_T("Not a valid search path")); }
Last edited by Fordy; 06-22-2002 at 11:28 AM.