Ejemplo n.º 1
0
  bool GetCurrentDirectoryX(std::basic_string<Char, Traits, Alloc>& out)
  {
    Blob<Char> buf;
    //TCHAR* tsz = 0;
    DWORD dwRet = 0;
    bool r = false;

    dwRet = GetCurrentDirectoryW(static_cast<DWORD>(buf.Size()), buf.GetBuffer());
    if(dwRet)
    {
      if(dwRet > static_cast<DWORD>(buf.Size()))
      {
        // It needs more space.
        if(buf.Alloc(dwRet+2))
        {
          if(::GetCurrentDirectory(static_cast<DWORD>(buf.Size()), buf.GetBuffer()))
          {
            out = buf.GetBuffer();
            r = true;
          }
        }
      }
      else
      {
        out = buf.GetBuffer();
        r = true;
      }
    }

    return r;
  }
Ejemplo n.º 2
0
  inline HRESULT SHGetFolderPathX(std::basic_string<Char, Traits, Alloc>& sOut, int nFolder)
  {
    bool r = false;
		Blob<wchar_t, BlobTraits<true, MAX_PATH> > buf;
		HRESULT hr;
		if(SUCCEEDED(hr = SHGetFolderPathW(NULL, nFolder, NULL, SHGFP_TYPE_CURRENT, buf.GetBuffer())))
    {
			StringConvert(buf.GetBuffer(), sOut);
    }
		return hr;
  }
Ejemplo n.º 3
0
 inline HMODULE LoadLibraryX(const Char* buffer)
 {
   Blob<wchar_t, false, BlobTraits<true, MAX_PATH> > t;
   t.Alloc(StringLength(buffer) + 1);
   t.GetWritableBuffer()[0] = 0;
   XLastDitchStringCopy(buffer, t.GetWritableBuffer());
   return LoadLibraryW(t.GetBuffer());
 }
Ejemplo n.º 4
0
 inline int LoadStringX(HINSTANCE hInstance, UINT id, Char* buffer, int buffermax)
 {
   Blob<wchar_t, false, BlobTraits<true, 1024> > t;
   t.Alloc(buffermax + 1);
   t.GetWritableBuffer()[0] = 0;
   int r = LoadStringW(hInstance, id, t.GetWritableBuffer(), buffermax);
   XLastDitchStringCopy(t.GetBuffer(), buffer);
   return r;
 }