用SerchPath(..)就可以了。
如下例,检查d:\mydir\myavi.avi是否存在。
if (SearchPath("d:\\mydir","myavi.avi",NULL,MAX_PATH,filepath,NULL) )
{ Play(filepath,hWnd); }
如下例,检查d:\mydir\myavi.avi是否存在。
if (SearchPath("d:\\mydir","myavi.avi",NULL,MAX_PATH,filepath,NULL) )
{ Play(filepath,hWnd); }
BOOL FileExists(CString name)
{
OFSTRUCT ofn;
if(OpenFile((LPCSTR)name,&ofn,OF_EXIST)!=HFILE_ERROR)
return TRUE;
else
return FALSE;
}
LPCTSTR lpFileName, // file name
DWORD dwDesiredAccess, // access mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile // handle to template file
);