Install Silverlight pseudo winfrom Using InstallShield

Source: Internet
Author: User
Tags strfind

As we all know, the Silverlight OOB mode can be directly installed right-click in the browser,
Here I will introduce how to use SilverlightProgramCreate an independent EXE installer.
Ideas:
1. Install xap through command line
2. After installation, uninstall the xap that comes with OOB In the delete control panel.
3. InstallShield installer uninstall and also uninstall the Silverlight Program

Prerequisites:
Reading this articleArticleYou need to understand the Silverlight deployment and InstallShield technology before.

Thanks:
Thanks to my friend ftpwmd for providing InstallShield technical support.

For the sllauncher command, see:
Http://tech.it168.com/a2010/0810/1088/000001088696_1.shtml

InstallShieldCode:

Code

  // Custom Functions  
Export prototype bool saveuninstall ( String );
Export prototype bool remomveuninstall ();
Export prototype installxap ();
Export prototype uninstallxap ();
Export prototype checksilverlightandinstall ();

// Check whether Silverlight is installed
Function checksilverlightandinstall ()
String szname;
Number nreturn;
Begin

Regdbsetdefaultroot (HKEY_LOCAL_MACHINE );
Szname = " Software \ Microsoft \ Silverlight " ;
Nreturn = Regdbkeyexist (szname );
If (Nreturn < 0 ) Then
Launchappandwait (supportdir ^ " Silverlight.exe " , "" , Wait );
Endif;

End;

// Save uninstall information
Function bool saveuninstall (szpath)

String szname, sztitle, szvalue;

Number ntype, nsize, nvtype, nvsize;
Begin

Regdbsetdefaultroot (HKEY_CURRENT_USER );

Szname = " Uninstallstring " ;

Ntype = Regdb_string;

Nsize = - 1 ;

Regdbgetkeyvalueex (szpath, szname, nvtype, szvalue, nvsize ); Regdbsetkeyvalueex ( " Software \ chuifeng " , " Uninstall " , Regdb_string, szvalue, - 1 );

End;

// How to delete an xap instance
Function bool remomveuninstall ()
String Szkey1, svstring, svtring1;
List listsubkeys, listnames;
Number nreturn, nresult, nvitem, nlocation;
Begin

Szkey1 = " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall " ;

Listsubkeys = Listcreate (stringlist );
Listnames = Listcreate (stringlist );

If (Listnames = List_null) | (Listsubkeys = List_null) then
MessageBox ( " Unable to create necessary lists. " , Severe );
Abort;
Endif;

Regdbsetdefaultroot (HKEY_CURRENT_USER );

Nreturn = Regdbquerykey (szkey1, regdb_keys, listsubkeys );

If (Nreturn > = 0 ) Then

Nreturn = Listgetfirststring (listsubkeys, svstring );

While (Nreturn ! = End_of_list)

Nlocation = Strfind (svstring, " Imd.mdrtbase.com " );
If (Nlocation > = 0 ) Then // Not found

Svtring1 = Szkey1 + " \\ " + Svstring;

Saveuninstall (svtring1 );

Regdbdeletekey (svtring1 );

Return True;
Endif;

Nresult = Listgetnextstring (listsubkeys, svstring );

Endwhile;

Endif;

Listdestroy (listnames );
Listdestroy (listsubkeys );
End;

// Install Silverlight xap
Function installxap ()
String Szprogram, szcmdline, szxappath, szurl, szcommd;
Begin
Szprogram = " C: \ Program Files \ Microsoft Silverlight \ sllauncher.exe " ;
Szxappath = Supportdir ^ " Chuifeng. xap " ;
Szurl = " Http://www.chuifeng.com/ClientBin/chuifeng.xap " ;
Szcommd = " /Overwrite/shortcut: desktop + startmenu " ;
Szcmdline = " /Install :\ "" + Szxappath + " \ "" + Szcommd + " /Origin: " + Szurl;
Launchappandwait (szprogram, szw.line, wait );
End;

// Uninstall Silverlight xap
Function uninstallxap ()
String szkey, szname, szvalue, sztitle, szmsg, szcommand, szpament;

Number ntype, nsize, nvtype, nvsize, nvcount, nvlength;
Begin
Regdbsetdefaultroot (HKEY_LOCAL_MACHINE );

Szkey = " Software \ chuifeng " ;

Szname = " Uninstall " ;

Ntype = Regdb_string;

Nsize = - 1 ;

If (Regdbgetkeyvalueex (szkey, szname, nvtype, szvalue, nvsize) < 0 ) Then
MessageBox ( " Regdbgetkeyvalueex failed. " , Severe );
Else
Nvcount = Strfind (szvalue, " -Uninstallapp " );
Strsub (szcommand, szvalue, 0 , Nvcount );
Nvlength = Strlength (szvalue );
Strsub (szpament, szvalue, nvcount, nvlength );
Launchappandwait ( " \ "" + Szcommand + " \ "" , Szpament, wait );
Endif;
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.