一、需要的头文件:
#include <SWInstApi.h>
#include <SWInstDefs.h>
二、需要的LIB库:
swinstcli.lib
三。需要的能力:
TrustedUI
四、安装应用程序 :
_LIT( KTempPath , "c://SilTest.SISx" );
CAOSync* waiter = CAOSync::NewL();
CleanupStack::PushL( waiter );
iOptions.iUpgrade = SwiUI::EPolicyNotAllowed;
iOptions.iOCSP = SwiUI::EPolicyNotAllowed;
iOptions.iDrive = 'C';
iOptions.iUntrusted = SwiUI::EPolicyNotAllowed;
iOptions.iCapabilities = SwiUI::EPolicyNotAllowed;
iOptionsPckg = iOptions;
TBufC<200> FName(KTempPath);
//Silent insatllation
iLauncher.SilentInstall(waiter->iStatus,FName,iOptionsPckg);
waiter->Execute();
CleanupStack::PopAndDestroy( waiter );
五。卸载应用程序 :
const TUid KMyAppUid = {0x12345678} ;
//Silent insatllation
SwiUI::TUninstallOptions options;
SwiUI::TUninstallOptionsPckg optionsPckg;
options.iKillApp = SwiUI::EPolicyAllowed;
options.iBreakDependency = SwiUI::EPolicyAllowed;
optionsPckg = options;
iLauncher.SilentUninstall(KMyAppUid, optionsPckg, SwiUI::KSisxMimeType);
六,参考资料:
/S60_3rd_SDK_MR_API_Plug-In_Pack_v5_43
下载地址:
SilentInst.zip
http://wiki.forum.nokia.com/images/2/2f/SilentInst.zip
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/brew2003/archive/2008/12/23/3587982.aspx
简单的同步方式卸载,一个函数就实现了
//*************************************************
// author: jeme
//*************************************************
TBool DeleteApplication(const TUint32 aUid)
{
TBool re = ETrue;
TUid uid;
uid.iUid = aUid;
SwiUI::RSWInstSilentLauncher launcher;
TInt err = launcher.Connect();
if(err != KErrNone)
{
re =EFalse;
return re;
}
CleanupClosePushL( launcher );
SwiUI::TUninstallOptions options;
options.iBreakDependency = SwiUI::EPolicyAllowed;
options.iKillApp = SwiUI::EPolicyAllowed;
SwiUI::TUninstallOptionsPckg optPckg( options );
TRequestStatus status = KRequestPending;
launcher.SilentUninstall( status, uid,optPckg,SwiUI::KSisxMimeType());
if(status != KRequestPending)
{
re = EFalse;
}
while( status == KRequestPending )
{
User::After(5000); // 或者可以做其他事情
}
if(status != KErrNone)
{
re = EFalse;
}
launcher.CancelAsyncRequest( SwiUI::ERequestSilentUninstall );
CleanupStack::PopAndDestroy( &launcher );
return re;
}