经过多方调试总结出下列函数以供快捷开发使用。
PCHAR GetFileDirectory(CString file)
{
DWORD dwPos;
CString path;
GetModuleFileName(NULL,path.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
path.ReleaseBuffer();
dwPos = path.ReverseFind('\\');
// path = path.Left(pos);
// printf("sizeof :%d\n",path.GetLength());
path = path.Left(dwPos+1) + file;
// SetDlgItemText(IDC_EDIT3,path);
int iLen = sizeof(char)*path.GetLength()*2+1;
char *pFile = (char*)malloc(iLen);
memset(pFile,0,iLen);
WideCharToMultiByte(0,0,path.GetString(),path.GetLength(),pFile,iLen,NULL,NULL);
delete(pFile);
return pFile;
}