Sadly VC++ is not my game. I need some help, I'm totally lost.
The piece of code below allows the user to select a file through an "Open" dialog at which point the function converts the file to another file type.
The goal is to eliminate the file selection process and replace it with automatic processing based on a predefined dir. I've been stumbling my way through this and I'm now stuck.
Original Code:
Code:
case ID_OPENFILE_BTTN: {
char szPath[MAX_PATH] ;
char * pPathLast ;
char szWAVFileName[MAX_PATH] ;
char * lpExtention ;
if ( hDS1DataFile ) {
CloseHandle( hDS1DataFile ) ;
hDS1DataFile = NULL ;
}
lpDSSFileName = GetDSSFile(hWnd) ;
if (lpDSSFileName != NULL) {
strcpy(szPath, lpDSSFileName) ;
pPathLast = strrchr( szPath, '\\') ;
pPathLast[1] = 0 ;
uiStatus= DSSActiveFolder(szPath, FALSE) ;
uiStatus = DSSActiveFile(lpDSSFileName, &dwMilliTotal, &DSSFileProperty) ;
}
strcpy(szWAVFileName, lpDSSFileName) ;
lpExtention = strrchr( szWAVFileName, '.') ;
strcpy(lpExtention+1, "wav") ;
// decoder flag setting
dwDecFlag = DSS_CONV_WAVFILE | DSS_INIT_DEC | DSS_CHANGE_PLAYPOS | DSS_USE_POSTFILT ;
if ( DSSFileProperty.bQuarity == MIX_RECORDED )
dwDecFlag |= DSS_MIXED_FILE ;
// Create WAV file header
if ( DSS_SetupWavConversion(szWAVFileName, FALSE) != DSS_SUCCESS) {
MessageBox(hWnd, "WAV header creating error!", "Error", MB_OK | MB_ICONEXCLAMATION);
return TRUE ;
}
uiStatus = DSSStartPlayback( 0, 0);
if (uiStatus == DSS_SUCCESS) {
bConvertWAVFile = TRUE ;
dwCurPosTime = 0 ;
dwStatus = DSS_WAVE ;
SendMessage(GetDlgItem(hWnd, ID_PLAYPOS_SLDR), TBM_SETPOS, TRUE, dwCurPosTime) ;
}
break ;
}
I found some sample code that loads all files of one type, in a predefined dir, into an array, which seems like the answer. The dir and file type is "A:\\*.txt" in the example when I would need "C:\\upload\\*.dss" .
File Loop Code:
Code:
...
const char p[] = "A:\\*.txt";
...
WIN32_FIND_DATA info;
HANDLE h;
if ((h = FindFirstFile(p,&info)) != INVALID_HANDLE_VALUE)
{
do
{
// Now file name C-string is in info.cFileName array
...
} while(FindNextFile(h,&info));
FindClose(h);
}
else ... // No such files.
I'm sure that this or some variation is the answer. I always know the dir of these files and after initiation of the program there is no need for human interaction in the process. Can't make it work.
Being unfamiliar with C++ is making this process brutal. Any help combining these code samples would be GREATLY appreciated.