TCHAR szDirectory[MAX_PATH] = {0};
GetCurrentDirectory(MAX_PATH, szDirectory);
szDirectory += "\\cat.wav"
PlaySound(szDirectory , NULL, SND_FILENAME | SND_ASYNC);
GetCurrentDirectory(MAX_PATH, szDirectory);
szDirectory += "\\cat.wav"
PlaySound(szDirectory , NULL, SND_FILENAME | SND_ASYNC);
编译的时候出错,提示error C2297: “+=”: 非法,右操作数包含“const char [8]”类型
GetCurrentDirectory(MAX_PATH, szDirectory);CString sndPath;
sndPath.Format("%s\\cat.wav", szDirectory);
//如果GetCurrentDirectory获取的当前路径最后已经有“\\”
//这块就是:sndPath.Format("%scat.wav", szDirectory);
PlaySound(sndPath, NULL, SND_FILENAME | SND_ASYNC);
用GetModuleFileName构建相对路径 getcurrentdirectory会变的