首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian英文资料 >> Tips Tricks >> 正文
How to let a DLL know which application uses it
作者:佚名    文章来源:不详    更新时间:2006-5-7 11:25:50

This question has been raised several times in the forum and as I had to implement such feature in one of our development here is a small tip that retrieves the name of the application that calls a DLL:


// Note: link against cone.lib, apparc.lib and eikcore.lib
#include <apparc.h>
#include <eikapp.h>
#include <eikappui.h>
#include <coemain.h>

/**
* Get the full path of the callin app
* (ex: "c:\system\myapp\myapp.app")
* @param aPath On exit, contains the full path to the application.
* The descriptor should be big enough to hold a full file name (i.e. 255 characters)
*/
EXPORT_C void MyDll::GetCallingAppPath(TDes& aPath)
{     aPath=((CEikAppUi*)CCoeEnv::Static()->AppUi())->Application()->DllName();
}

You can also use the function above to get the drive on which the DLL is installed (provided that the application and your DLL are part of the same package and installed on the same drive):


/**
* Get the drive on which the DLL is installed
* (It is assumed that the app and the DLL are part of the same
* SIS file and that the PKG specifies same drive for both)
* @param aDrive On exit, contains the full path to the application.
* The descriptor should be big enough to hold a full file name (i.e. 255 characters)
* Note: take care that this code is designed as this for simplicity
* but it uses 1KB of stack (512 bytes for the TFileName
* and a little bit more for the TParse object)
*/
EXPORT_C void MyDll::GetInstallationDrive(TDes& aDrive)
{    
 // Get the path of the calling application
 TFileName appPath;
 GetCallingAppPath(appPath);

 // Parse the app name to get the drive
 TParse parser;
 parser.Set(appPath,NULL,NULL);
 aDrive=parser.Drive();
}
相关文章:
Observer Pattern in Symbian application
Change the application language at runtime for Series 60 3rd Ed.
How to detect if an application is launched by user or the startup list
Tips & code samples for Sony Ericsson’s UIQ 3 based phones
Enable Skin support in your Symbian OS applications
How to reset/reformat a phone
Tracking down memory leaks
Obtain IMEI number of your symbian phone from Your Go-DB application
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号