here's a snippet from a MP3 player I made a while ago...
Code:
char pathname[255]={0};
struct _finddata_t fileinfo;
long findhandle;
GetDlgItemText(hwnd, IDC_FOLDER, pathname, 255);
strcat(pathname,"*.mp3");
findhandle = _findfirst(pathname,&fileinfo);
if (findhandle==-1)
{
MessageBox(NULL, "Directory Not Found", "Error", MB_OK);
return FALSE;
}
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)fileinfo.name);
while(_findnext(findhandle,&fileinfo)==0)
{
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)fileinfo.name);
}
It's a lot better than using LB_DIR because it gives the full filename, not just the DOS version.