一、需要的標頭檔:
#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
:
http://www.forum.nokia.com/info/sw.nokia.com/id/53439e01-f605-4491-96f4-62d003bd4c0c/S60_3rd_SDK_MR_API_Plug-In_Pack1.zip.html
SilentInst.zip
http://wiki.forum.nokia.com/images/2/2f/SilentInst.zip
本文來自CSDN部落格,轉載請標明出處:http://blog.csdn.net/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;
}