×
Namespaces

Variants
Actions

判断应用程序的路径

From Nokia Developer Wiki
Jump to: navigation, search
  • 详细描述

最终用户可以选择将程序安装到C盘或E盘。程序有时需要知道自己的安装位置。而这个要根据S60平台的版本来决定判断方式。

  • 解决方案

S60第二版

在S60第二版上,使用aknutils.h方法的CompleteWithAppPath( TDes& aFileName )方法。所有的组成部分都在给定的描述符中(盘符,路径和文件名,以及后缀),通过返回值返回,任何缺少的组成部分(路径和盘符)都从程序路径中获取(<drive>:\system\apps\<application_name> directory)。

#include <aknutils.h>
 
// Insert the full application path into the file name (fileName)
TFileName fullPath(fileName);
CompleteWithAppPath(fullPath); // from aknutils.h


  • S60第三版

从S60第三版之后,所有的程序二进制文件(EXE和DLL文件)都存放在\sys\bin目录下面,要访问这些目录,程序需要AllFiles能力。资源和数据不要存放在此目录下。相反程序有自己目录\private\<SID>\,这里SID为安全标识符。将每个进程区别开来。程序使用私有目录来存放.ini,.mbm,.rsc,和数据文件等,其他程序无法访问这些数据,除非拥有AllFiles能力。


CompleteWithAppPath()将返回\sys\bin作为程序第三版程序安装路径。要访问存放在私有目录下的程序数据,就需要另一个方法来完成:

TFileName appPath;
TBuf<2> appDrive;
 
// Returns private path of this application
// in following format: \Private\<SID of the application>\
// (does not contain drive specification).

iEikonEnv->FsSession().PrivatePath( appPath );
 
// Extract drive letter into appDrive
appDrive.Copy(iEikonEnv->EikAppUi()->Application()->AppFullName().Left(2));
 
// Insert drive letter into path
appPath.Insert(0, appDrive);

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

   
This page was last modified on 19 September 2012, at 03:14.
59 page views in the last 30 days.