游泳

高手进阶:给WINDOWS服务加上描述之四

2019-12-04 11:57:13来源:励志吧0次阅读

¡¡¡¡

ServiceFailureActions.lpsaActions = iScActionsPointer.ToInt32();

bChangeServiceConfig2 = modAPI.ChangeServiceConfig2A(iServiceHandle,

modAPI.InfoLevel.SERVICE_CONFIG_FAILURE_ACTIONS,ref ServiceFailureActions);

if (bChangeServiceConfig2==false)

{

throw new Exception("²»ÄÜÉèÖ÷þÎñµÄ¹ÊÕϻָ´ÉèÖÃ.");

}

}

catch(Exception ex)

{

throw new Exception(ex.Message);

}

finally

{

Marshal.FreeHGlobal(iScActionsPointer);

if (iServiceHandle > 0)

{

bCloseService = modAPI.CloseServiceHandle(iServiceHandle);

}

if (iSCManagerLockHandle > 0)

{

bUnlockSCManager = modAPI.UnlockServiceDatabase(iSCManagerLockHandle);

}

if (iSCManagerHandle != 0)

{

bCloseSCManager = modAPI.CloseServiceHandle(iSCManagerHandle);

}

}

}

ÔÚ°²×°Íê³Éºó£¬ÎÒÃǶԷþÎñ½øÐС£ÕâÀï¿ÉÒÔÐ޸ĵÄÄÚÈÝ°üÀ¨·þÎñµÄÃèÊö£¬·þÎñµÄ¹ÊÕÏ´¦ÀíµÈ.

Èç¹ûÄãÔÚ°²×°Ê±£¬ÐèÒª¶Ô·þÎñ½øÐÐ×Ô¶¯´¦ÓÚÔËÐÐ״̬£¬»òжÔØʱÐèÒª×Ô¶¯½«·þÎñҲжÔØ£¬ÄãֻҪע²á

this.beforeuninstall+=new InstallEventHandler(ProjectInstaller_BeforeUninstall);

this.Committed+=new InstallEventHandler(ProjectInstaller_Committed);

Õâ¶þ¸öʼþ

committedʼþ£¬ÔÚÕâÀï¿ÉÒÔ½«°²×°µÄ·þÎñ½øÐе÷Õûµ½ÔËÐÐ״̬

beforeuninstallʼþ£¬Äú¿ÉÒÔÔÚÕâÀォ·þÎñ×Ô¶¯Ð¶Ôصô

²é¿´±¾ÎÄÀ´Ô´

分享到: