CString GetCurrentDir(void)
{
TCHAR sDrive[_MAX_DRIVE];
TCHAR sDir[_MAX_DIR];
TCHAR sFilename[_MAX_FNAME];
TCHAR Filename[_MAX_FNAME];
TCHAR sExt[_MAX_EXT];
GetModuleFileName(AfxGetInstanceHandle(),Filename,_MAX_PATH);
_tsplitpath(Filename,sDrive,sDir,sFilename,sExt);
CString HomeDir(CString(sDrive)+CString(sDir));
if (HomeDir.GetAt(HomeDir.GetLength()-1)!=_T('\\'))
HomeDir+=_T('\\');
return HomeDir;
}
char path[256];
sprintf(path, "%splaylist1.txt", GetCurrentDir());
result = AddWindowEx(iCom, iAddress, iSchedule, 0, 0, 128, 32, path);
if (!result)
AfxMessageBox("设置播放数据playlist1.txt失败");
我怎么调用AddWindowEx 这个方法
主要是 sprintf(path, "%splaylist1.txt", GetCurrentDir()); 这一句是干嘛的 百度了一圈也没看到答案 有没有c++大神 帮忙看看
sprintf can be replaced by C#'s
string.Format()
. If you use C#6, you can directly write the template string$""
, and GetCurrentDir should be replaced byEnvironment.CurrentDirectory
.Is AddWindowEx a custom function?
c# can only call c functions through the platform
Then just call the method directly
String formatting function, encyclopedia has entry