在MFC中的Windows Mobile应用程序中设置路径 [英] set the path in windows mobile application in MFC

查看:48
本文介绍了在MFC中的Windows Mobile应用程序中设置路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发Windows Mobile的应用程序.我要设定路径.我无法像在简单MFC应用程序中使用的那样使用功能Setcurrentdirectory.请告诉我如何设置路径并在Windows设备应用程序文件夹中的特定位置运行文件.

Hello All,

I am developing the application for windows mobile. I want to set the path. I am not able to use the function Setcurrentdirectory as I can use in Simple MFC application. Please advice me how to set the path and run a file in the perticular location in the folder in windows device application

推荐答案

//我想设置路径

您可以尝试对任何文件操作进行显式设置:):
// I want to set the path

You could try to set it explicitly, for any file operation :) :
class CPathHolder : public CString
{
public:
  CPathHolder() :
#ifdef UNDER_CE // or another of your mobile defines
  CString(_T("\\Work\\your_files\\")) {} // or another default for CE
#esle
  CString(_T("C:\\Work\\your_files\\")) {} // or another default for PC
#endif
}

/*global*/ CString& GetPathHolder()
{
  static CPathHolder cPathHolder;
  return cPathHolder;
}

/*global*/ CString& GetCurrentPath()
{
  return GetPathHolder();
}

/*global*/ void SetCurrentPath(const CString& cszNewPath)
{
  GetPathHolder() = cszNewPath;
}

void CYourApp::CYourApp()
{
  SetCurrentPath(
#ifdef UNDER_CE
    _T("\\Work\\PhotoViewer\\LastFiles\\")
#else
    _T("C:\\Work\\PhotoViewer\\LastFiles\\")
#endif
  );

  //...
}

void CYourApp::ShowPngFile(const CString& cszPngFileNameWithoutPath)
{
  CString cszFullFileName(GetCurrentPath() + cszPngFileNameWithoutPath);

  //...
}


这篇关于在MFC中的Windows Mobile应用程序中设置路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆