Following content is directly reprinted from From MSI to WiX, Part 19 - The Art of Custom Action, Part 1

Author:Alex Shevchuk

Introduction

Today we will start exploring custom actions, how to write them, what makes custom action good custom action and everything else related to custom actions.

Let's start with very simple sample.  We have an application which creates a new file during run-time and this file is not part of originally installed files.  On uninstall we need to delete this file as well.  The name of the file is well known.

Here is the source for our test console application:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO; namespace Test
{
class Program
{
static void Main(string[] args)
{
using (StreamWriter fs = File.CreateText("Test.txt"))
{
fs.Write("Hello");
} Console.WriteLine("Bye");
}
}
}

During run time our program creates Test.txt file which we want to remove on our test application uninstall.  Because new file name is well known, all we need to do is to add RemoveFile element:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{2F59639E-4626-44f8-AAF0-EE375B766221}"
Name="Test Application"
Language="1033"
Version="0.0.0.0"
Manufacturer="Your Company">
<Package Id="????????-????-????-????-????????????"
Description="Shows how to delete run-time file with known file name."
Comments="This will appear in the file summary stream."
InstallerVersion="200"
Compressed="yes" /> <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Test1" LongName="Test for removal of run time file"> <Component Id="ProductComponent"
Guid="{8F4CC43A-9290-4c93-9B97-B9FC1C3579CC}">
<File Id="Test.exe" DiskId="1" Name="Test.exe"
Source="..\Test\bin\Debug\Test.exe" KeyPath="yes" /> <RemoveFile Id="Test.txt" On="uninstall" Name="Test.txt" />
</Component> </Directory>
</Directory>
</Directory> <Feature Id="ProductFeature" Title="Feature Title" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>

To test our install, install application, go to installation folder and run Test.exe.  Application will create Test.txt file.  Uninstall application and make sure that installation folder is gone.

There is no need for custom action in here.  Things are more complicated if our program creates file or files with unknown at installation creation package time.

Here is an updated version of Test application.  It creates a file with arbitrary name:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO; namespace Test
{
class Program
{
static void Main(string[] args)
{
using (StreamWriter fs = File.CreateText(DateTime.Now.Ticks.ToString()+ ".log"))
{
fs.Write("Hello");
} Console.WriteLine("Bye");
}
}
}

Because we don't know the name of the new file we need custom action which will find this new file and delete it.  This custom action must be deferred and, for simplicity sake, we will be using VBScript custom action type 38 (seeintroduction to custom actions for more details).  Because our custom action is deferred, we will pass all required parameters through CustomActionData property (see here for details).

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{2F59639E-4626-44f8-AAF0-EE375B766221}"
Name="Test Application"
Language="1033"
Version="0.0.0.0"
Manufacturer="Your Company">
<Package Id="{58BCF2DD-16A0-4654-B289-F13AADA240CD}"
Description="Shows how to delete run-time file with known file name."
Comments="This will appear in the file summary stream."
InstallerVersion="200"
Compressed="yes" /> <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Test1" LongName="Test for removal of run time file"> <Component Id="ProductComponent"
Guid="{8F4CC43A-9290-4c93-9B97-B9FC1C3579CC}">
<File Id="Test.exe" DiskId="1" Name="Test.exe"
Source="..\Test\bin\Debug\Test.exe" KeyPath="yes" />
</Component> </Directory>
</Directory>
</Directory> <CustomAction Id="RemoveTempFile" Script="vbscript" Execute="deferred">
<![CDATA[
On error resume next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(Session.Property("CustomActionData") + "*.log")
Set fso = Nothing
]]>
</CustomAction> <CustomAction Id="SetCustomActionData"
Property="RemoveTempFile" Value="[INSTALLLOCATION]" /> <InstallExecuteSequence>
<Custom Action="SetCustomActionData" Before="RemoveTempFile">REMOVE="ALL"</Custom>
<Custom Action="RemoveTempFile" Before="RemoveFiles">REMOVE="ALL"</Custom>
</InstallExecuteSequence> <Feature Id="ProductFeature" Title="Feature Title" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>

Few things to notice in here.  First of all, we need to set CustomActionData property before our RemoveTempFile custom action.  RemoveTempFile custom action must be scheduled before RemoveFiles standard action because this standard action decides on whether installation folder will be removed or not.  If at the end of RemoveFiles standard action folder is not empty, folder won't be deleted. That's why we want to delete extra files before RemoveFiles standard action.  Also, both custom actions are conditioned to run on complete uninstall only.

Let's test our installer.  Install application and run Test.exe a few times.  After every run you will see a new file being created.  Now uninstall the application.  Installation folder should disappear.

So, are we successfully solved the problem?  Let's create an uninstall failure condition.  In all good installation packages all changes made during uninstall should be rolled back in case of uninstall failure.  Let's see how we are doing.  The easiest way to create an uninstall failure is to schedule deferredcustom action type 54 right before InstallFinalize standard action.  We can't use custom action type 19 because this custom action does not allow setting execution option (in other words, it is always immediate custom action) and we want to fail an installation after we ran our RemoveTempFile custom action.

Here is our updated WiX source file:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{2F59639E-4626-44f8-AAF0-EE375B766221}"
Name="Test Application"
Language="1033"
Version="0.0.0.0"
Manufacturer="Your Company">
<Package Id="{58BCF2DD-16A0-4654-B289-F13AADA240CD}"
Description="Shows how to delete run-time file with known file name."
Comments="This will appear in the file summary stream."
InstallerVersion="200"
Compressed="yes" /> <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Test1" LongName="Test for removal of run time file"> <Component Id="ProductComponent"
Guid="{8F4CC43A-9290-4c93-9B97-B9FC1C3579CC}">
<File Id="Test.exe" DiskId="1" Name="Test.exe"
Source="..\Test\bin\Debug\Test.exe" KeyPath="yes" />
</Component> </Directory>
</Directory>
</Directory> <CustomAction Id="RemoveTempFile" Script="vbscript" Execute="deferred">
<![CDATA[
On error resume next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(Session.Property("CustomActionData") + "*.log")
Set fso = Nothing
]]>
</CustomAction> <CustomAction Id="SetCustomActionData"
Property="RemoveTempFile" Value="[INSTALLLOCATION]" /> <Property Id="FailureProgram">
<![CDATA[
Function Main()
Main = 3
End Function
]]>
</Property> <CustomAction Id="FakeFailure"
VBScriptCall="Main"
Property="FailureProgram"
Execute="deferred" /> <InstallExecuteSequence>
<Custom Action="SetCustomActionData" Before="RemoveTempFile">REMOVE="ALL"</Custom>
<Custom Action="RemoveTempFile" Before="RemoveFiles">REMOVE="ALL"</Custom> <Custom Action='FakeFailure' Before='InstallFinalize'>REMOVE="ALL" AND TESTFAIL</Custom>
</InstallExecuteSequence> <Feature Id="ProductFeature" Title="Feature Title" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>

FakeFailure custom action is running VBScript stored in the FailureProgram property.  This script just returns the value 3 which means that script has failed.  This return code will force Windows Installer engine to fail an uninstall and roll back all changes made up to this point.  We also put a condition on FakeFailure custom action to run on uninstall and only if TESTFAIL property is defined.  The reason for this is that we don't want our installation package to be stuck in uninstall failure.  Doing that will require use of MsiZap tool to remove our installation from the system.  Instead, we allow uninstall to succeed normally, but if we want to fail an installation we must use command line to do that:

msiexec /uninstall Project.msi TESTFAIL=YES

Let's install our test application, run Test.exe few times.  Make sure that we have few files created in the same folder where Test.exe is located.  Now try to uninstall program by running above mentioned command in the command window.  Installation will fail.  Go back to installation folder where Test.exe file is located and observe that all files created by Test.exe are gone.

Depending on what those files are that may be OK, but that could be a big problem.  Imagine, that our Test.exe is a personal finance management software (something like Microsoft Money) and it stores last synchronization  with bank's server data.  By removing those extra files we are forcing our software to resynch the whole transaction history on the next run.  That's bad.

So, how we can fix the problem.  Remember, that in addition to immediate and deferred custom actions we have also rollback (runs during rollback installation phase) and commit (runs at the end of successful transaction) custom actions.  Changes that we are going to make are:

  • Deferred custom action will move files to be deleted into temporary folder
  • Commit custom action will delete files from the temporary folder
  • Rollback custom action will move files back from temporary folder to installation folder

Because scripts will be larger than custom action type 38 can store we will be using custom action type 6 instead (again, see introduction to custom actionsfor more details).

Here is the deferred custom action (MoveTempFile.vbs):

Function Main()

    On Error Resume Next

    Dim properties, tempFile, fso, folder

    Const msiDoActionStatusSuccess = 

    properties = Split(Session.Property("CustomActionData"), ";", -, )
tempFile = properties() & "{42A7DCCB-868B-4D11-BBBE-5A32B8DF5CC9}\" Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.CreateFolder(tempFile)
fso.DeleteFile tempFile & "*.log", true
fso.MoveFile properties() & "*.log", tempFile
Set folder = Nothing
Set fso = Nothing Main = msiDoActionStatusSuccess End Function

In CustomActionData we will pass both INSTALLLOCATION and TempFolderproperties.  This script will create subfolder in the TempFolder.  Subfolder's name is the UpgradeCode Guid.  It will move log files from installation folder to temporary folder.

Commit script (CommitTempFile.vbs) will delete log files from temporary folder:

Function Main()

    On Error Resume Next

    Dim properties, tempFile, fso, folder

    Const msiDoActionStatusSuccess = 

    properties = Split(Session.Property("CustomActionData"), ";", -, )
tempFile = properties() & "{42A7DCCB-868B-4D11-BBBE-5A32B8DF5CC9}\" Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile tempFile & "*.log", true
Set fso = Nothing Main = msiDoActionStatusSuccess End Function

And Rollback script will move files back from temporary folder to installation folder:

Function Main()

    On Error Resume Next

    Dim properties, tempFile, fso

    Const msiDoActionStatusSuccess = 

    properties = Split(Session.Property("CustomActionData"), ";", -, )
tempFile = properties() & "{42A7DCCB-868B-4D11-BBBE-5A32B8DF5CC9}\" Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile tempFile & "*.log", properties()
Set fso = Nothing Main = msiDoActionStatusSuccess End Function

Here is the updated WiX source code:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{2F59639E-4626-44f8-AAF0-EE375B766221}"
Name="Test Application"
Language="1033"
Version="0.0.0.0"
Manufacturer="Your Company"
UpgradeCode="{42A7DCCB-868B-4D11-BBBE-5A32B8DF5CC9}">
<Package Id="{58BCF2DD-16A0-4654-B289-F13AADA240CD}"
Description="Shows how to delete run-time file with known file name."
Comments="This will appear in the file summary stream."
InstallerVersion="200"
Compressed="yes" /> <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Test1" LongName="Test for removal of run time file"> <Component Id="ProductComponent"
Guid="{8F4CC43A-9290-4c93-9B97-B9FC1C3579CC}">
<File Id="Test.exe" DiskId="1" Name="Test.exe"
Source="..\Test\bin\Debug\Test.exe" KeyPath="yes" />
</Component> </Directory>
</Directory>
</Directory> <Binary Id="MoveTempFileScript" SourceFile="MoveTempFile.vbs" />
<Binary Id="CommitTempFileScript" SourceFile="CommitTempFile.vbs" />
<Binary Id="RollbackTempFileScript" SourceFile="RollbackTempFile.vbs" /> <CustomAction Id="MoveTempFile"
BinaryKey="MoveTempFileScript"
VBScriptCall="Main"
Execute="deferred"
Return="check" /> <CustomAction Id="CommitTempFile"
BinaryKey="CommitTempFileScript"
VBScriptCall="Main"
Execute="commit"
Return="check" /> <CustomAction Id="RollbackTempFile"
BinaryKey="RollbackTempFileScript"
VBScriptCall="Main"
Execute="rollback"
Return="check" /> <CustomAction Id="SetMoveData"
Property="MoveTempFile" Value="[INSTALLLOCATION];[TempFolder]" /> <CustomAction Id="SetCommitData"
Property="CommitTempFile" Value="[INSTALLLOCATION];[TempFolder]" /> <CustomAction Id="SetRollbackData"
Property="RollbackTempFile" Value="[INSTALLLOCATION];[TempFolder]" /> <Property Id="FailureProgram">
<![CDATA[
Function Main()
Main = 3
End Function
]]>
</Property> <CustomAction Id="FakeFailure"
VBScriptCall="Main"
Property="FailureProgram"
Execute="deferred" /> <InstallExecuteSequence>
<Custom Action="SetMoveData" Before="MoveTempFile">REMOVE="ALL"</Custom>
<Custom Action="MoveTempFile" Before="RemoveFiles">REMOVE="ALL"</Custom> <Custom Action="SetCommitData" Before="CommitTempFile">REMOVE="ALL"</Custom>
<Custom Action="CommitTempFile" After="MoveTempFile">REMOVE="ALL"</Custom> <Custom Action="SetRollbackData" Before="RollbackTempFile">REMOVE="ALL"</Custom>
<Custom Action="RollbackTempFile" After="MoveTempFile">REMOVE="ALL"</Custom> <Custom Action='FakeFailure' Before='InstallFinalize'>REMOVE="ALL" AND TESTFAIL</Custom>
</InstallExecuteSequence> <Feature Id="ProductFeature" Title="Feature Title" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>

You can test it now to make sure that on uninstall failure all files get restored.

So, are we done yet?  Not quite.  Why?  Because there is much better alternativefor this type of tasks.  What we can do is populate RemoveFile table, just like WiX did for us in our first sample when we wanted to remove file with well-known name.  Just open msi file from Step 1 using Orca tool.  You will see RemoveFiletable on the left:

FileKey Component_ FileName DirProperty InstallMode
Test.txt ProductComponent Test.txt INSTALLLOCATION 2

Time to make an excuse:  Those who pay attention to what they read have alredy noticed that FileName column of RemoveFile table has WildCardFilename type and therefore allows using wildcards.  So, why I did not make my component something like this and called it done:

<Component Id="ProductComponent" Guid="{8F4CC43A-9290-4c93-9B97-B9FC1C3579CC}">
<File Id="Test.exe" DiskId="1" Name="Test.exe" Source="..\Test\bin\Debug\Test.exe" KeyPath="yes" />
<RemoveFile Id="RemoveTempFiles" On="uninstall" Name="*.log" />
</Component>

Well, my goal was to show why do we need rollback and commit custom actions.  Let's imagine for a moment that we are dealing with unknown at compile time set of file extensions and continue with our discussion.

So, what we are going to do with our immediate custom action is populate this table with the names of the files created by our application during run-time.  After that, Windows Installer will take care of Commit and Rollback actions, so we won't need these custom actions anymore.  Custom action must be an immediate custom action because during deferred phase session and database handle are no longer accessible.

Here is the source of the custom action:

Function Main()

    On Error Resume Next

    Dim fso, folder, files
Dim DirProperty, ComponentId, InstallFolder
Dim database, view, record Const msiDoActionStatusSuccess =
Const msiViewModifyInsertTemporary = InstallFolder = Session.Property("INSTALLLOCATION")
ComponentId = "ProductComponent"
DirProperty = "INSTALLLOCATION" Set database = Session.Database
Set view = database.OpenView("SELECT `FileKey`, `Component_`, `FileName`, `DirProperty`, `InstallMode` FROM `RemoveFile`")
view.Execute Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(InstallFolder)
Set files = folder.Files
For Each file in files
If fso.GetExtensionName(file.name) = "log" Then
Set record = installer.CreateRecord()
record.StringData() = file.name
record.StringData() = ComponentId
record.StringData() = file.name
record.StringData() = DirProperty
record.IntegerData() = view.Modify msiViewModifyInsertTemporary, record
End If
Next view.Close
Set view = Nothing
database.Commit
Set database = Nothing Set files = Nothing
Set folder = Nothing
Set fso = Nothing Main = msiDoActionStatusSuccess End Function

It opens installer's database and inserts temporary records into RemoveFiletable.

Here is updated WiX source code:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi">
<Product Id="{2F59639E-4626-44f8-AAF0-EE375B766221}"
Name="Test Application"
Language="1033"
Version="0.0.0.0"
Manufacturer="Your Company"
UpgradeCode="{42A7DCCB-868B-4D11-BBBE-5A32B8DF5CC9}">
<Package Id="{58BCF2DD-16A0-4654-B289-F13AADA240CD}"
Description="Shows how to delete run-time file with known file name."
Comments="This will appear in the file summary stream."
InstallerVersion="200"
Compressed="yes" /> <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Test1" LongName="Test for removal of run time file"> <Component Id="ProductComponent"
Guid="{8F4CC43A-9290-4c93-9B97-B9FC1C3579CC}">
<File Id="Test.exe" DiskId="1" Name="Test.exe"
Source="..\Test\bin\Debug\Test.exe" KeyPath="yes" /> <!--
Uncomment next line and comment out MoveTempFile custom action
to test wildcard file removal option
<RemoveFile Id="RemoveTempFiles" On="uninstall" Name="*.log" />
-->
</Component> </Directory>
</Directory>
</Directory> <EnsureTable Id="RemoveFile" /> <Binary Id="MoveTempFileScript" SourceFile="MoveTempFile.vbs" /> <CustomAction Id="MoveTempFile"
BinaryKey="MoveTempFileScript"
VBScriptCall="Main"
Execute="immediate"
Return="check" /> <Property Id="FailureProgram">
<![CDATA[
Function Main()
Main = 3
End Function
]]>
</Property> <CustomAction Id="FakeFailure"
VBScriptCall="Main"
Property="FailureProgram"
Execute="deferred" /> <InstallExecuteSequence>
<Custom Action="MoveTempFile" Before="RemoveFiles">REMOVE="ALL"</Custom> <Custom Action='FakeFailure' Before='InstallFinalize'>REMOVE="ALL" AND TESTFAIL</Custom>
</InstallExecuteSequence> <Feature Id="ProductFeature" Title="Feature Title" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>

One thing to notice here is that I am using new EnsureTable element.  WiX does not create standard tables if they are empty.  Because we don't have anywhere in our WiX code RemoveFile elements WiX will not create RemoveFile table.  HavingEnsureTable element tells to WiX compiler that RemoveFile table must be created even though it is empty.

In Part 2 we will try to make this custom action reusable.

Code is attached.

The Art of Custom Actions1.zip

WIX Custom Action (immediate, deffered, rollback)的更多相关文章

  1. Wix打包系列(三)自定义Action(Custom Action)

    原文:Wix打包系列(三)自定义Action(Custom Action) 3.1 关于Action 我们已经知道如何生成具有标准安装界面的安装程序了,Windows Installer按照我们的界面 ...

  2. SharePoint 2010/SharePoint 2013 Custom Action: 基于Site Collection 滚动文字的通知.

    应用场景: 有时候我们的站点需要在每个页面实现滚动文字的通知,怎么在不修改Master Page的情况下实现这个功能?我们可以使用Javascript 和 Custom Action 来实现. 创建一 ...

  3. How to debug Custom Action DLL

    在MSI工程中,经常会遇到这样的情况: MSI 工程需要调用DLL(C++)中的一个函数实现某些特殊或者复杂的功能,通常的做法是在Custom Action 中调用该DLL . 那么在安装过程中,该C ...

  4. Custom Action : dynamic link library

    工具:VS2010, Installshield 2008 实现功能: 创建一个C++ win32 DLL的工程,MSI 工程需要调用这个DLL,并将Basic MSI工程中的两个参数,传递给DLL, ...

  5. Installshield: custom action return value

    参考:MSDN: Custom Action Return Values 参考:MSDN: Logging of Action Return Values

  6. Default Custom Action Locations and IDs

    Default Custom Action Locations and IDs SharePoint 2013                             The following ta ...

  7. SharePoint 2013 - User Custom Action

    1. User Custom Action包含Ribbon和ECB,以及Site Action菜单等,参考此处: 2. 系统默认ECB的Class为: ms-core-menu-box --> ...

  8. Dynamics CRM 2015/2016 Web API:Unbound Custom Action 和 Bound Custom Action

    今天我们再来看看Bound/Unbound Custom Action吧,什么是Custom Action?不知道的小伙伴们就out了,Dynamics CRM 2013就有了这个功能啦.和WhoAm ...

  9. Win7 64X 安装VisualSVNServer 2.6.0过程中出现Custom action InstallWMISchemaExcute failed: Cannot query proxy blanket: No such interface supported (0x80004002)

    Win7 64X 安装VisualSVNServer 2.6.0过程中出现错误:Custom action InstallWMISchemaExcute failed: Cannot query pr ...

随机推荐

  1. Python中如何把一个UTC时间转换为本地时间

    需求: 将20141126010101格式UTC时间转换为本地时间. 在网上搜了好长时间都没有找到完美的解决方案.有的引用了第三方库,这就需要在现网安装第三方的软件.这个是万万不可的.因为真实环境不一 ...

  2. SQL Server 2005 盛宴系列 经典教程

    SQL Server 2005 盛宴系列 经典教程  [复制链接]   发表于 2007-3-27 14:08 | 来自 51CTO网页 [只看他] 楼主     TECHNET  SQL serve ...

  3. Tomcat服务器常用配置和HTTP简介

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...

  4. Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid

    F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  5. iOS开发——高级技术&密码锁功能的实现

    密码锁功能的实现 一个ios手势密码功能实现 ipad/iphone 都可以用 没有使用图片,里面可以通过view自己添加 keychain做的数据持久化,利用苹果官方KeychainItemWrap ...

  6. Javascript call与apply记录

    [注]:记录自己对javascript中call与apply的见解 总会有些东西会被人拿出来重复的写来写去,为何? 只是因为自己感觉不够了解,所谓好记性不如烂笔头,并且在写的同时也会或多或少的收获到一 ...

  7. PHP内核探索之变量 图解

    http://blog.csdn.net/ohmygirl/article/details/41542445 http://www.laruence.com/2008/09/19/520.html

  8. 返回类型和return语句

    return语句终止当前正在执行的函数并将控制权返回到调用该函数的地方.return语句有两种形式: return; return expression; 无返回值函数 没有返回值的return语句只 ...

  9. Unescape HTML entities in Javascript Unescape HTML转成html代码

    前言: 在javascript里面动态创建标准dom对象一般使用: var obj = document.createElement('div'); 然后再给obj设置一些属性. 但是,在实际使用过程 ...

  10. C#_delegate - 用委托实现事件,Display和Log类都使用Clock对象

    //public event SecondChangeHandler OnSecondChange; 若将委托加上event,则视作是事件,不是委托,外围就不能直接对OnSecondChange传值 ...