// CurrDir.cpp : Implementation of CCurrDir #include "stdafx.h" #include "DirControl.h" #include "CurrDir.h" #include "fileInfo.h" ///////////////////////////////////////////////////////////////////////////// // CCurrDir STDMETHODIMP CCurrDir::GetCurrDir(BSTR *dirPath) { const int MaxSize = 256; char Dir[MaxSize]; ::GetCurrentDirectory(MaxSize,Dir); *dirPath = SysAllocStringLen(0,strlen(Dir)); mbstowcs(*dirPath,Dir,strlen(Dir)); return S_OK; } STDMETHODIMP CCurrDir::SetCurrDir(BSTR dirPath) { const int MaxSize = 256; char Dir[MaxSize]; wcstombs(Dir,dirPath,wcslen(dirPath)+1); ::SetCurrentDirectory(Dir); return S_OK; } STDMETHODIMP CCurrDir::GetDirContents(BSTR *contents) { _bstr_t save = "\n "; fileInfo getFile("."); if(getFile.firstFile("*.*")) { save += getFile.name().c_str(); save += "\n "; } while(getFile.nextFile()) { save += getFile.name().c_str(); save += "\n "; } getFile.closeFile(); *contents = save; return S_OK; }