tchar.cpp 905 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Example use of Microsoft TCHAR ----------------------------------------------------//
  2. // Copyright Beman Dawes 2008
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. #include <boost/filesystem/path.hpp>
  6. #include <boost/filesystem/operations.hpp>
  7. #include <string>
  8. #include <cassert>
  9. #include <windows.h>
  10. #include <winnt.h>
  11. namespace fs = boost::filesystem;
  12. typedef std::basic_string<TCHAR> tstring;
  13. void func( const fs::path & p )
  14. {
  15. assert( fs::exists( p ) );
  16. }
  17. int main()
  18. {
  19. // get a path that is known to exist
  20. fs::path cp = fs::current_path();
  21. // demo: get tstring from the path
  22. tstring cp_as_tstring = cp.string<tstring>();
  23. // demo: pass tstring to filesystem function taking path
  24. assert( fs::exists( cp_as_tstring ) );
  25. // demo: pass tstring to user function taking path
  26. func( cp_as_tstring );
  27. return 0;
  28. }