Old 30th September 2017, 04:49   #1
demon.devin
Junior Member
 
Join Date: Sep 2017
Posts: 3
Question ServiceLib.nsh

I cannot seem to get a hold of the gentlemen who wrote the ServiceLib.nsh include file. So instead I've come here for help. I've created a set of macros for use with the ServiceLib.nsh header file. My question/favor to whom ever has extensive knowledge in NSIS (is a fellow by the name of Anders apart of this forum? Lol) is if they can assess these macros to see if they're written correctly and if they're ready for use in a production environment? I've tested them myself a couple of times already but I'd like a second opinion from someone more qualified.

My knowledge about Windows Services is a bit amateurish. With that being said, do I need to add anything to these macros? I'm asking because I'm going to be using this little library in an open source project I'm working on that will be using these macros heavily. Here's the macros I've written for use with the ServiceLib.nsh include file:

PHP Code:
;= ${ServiceLib::Create}
!
define ServiceLib::Create `!insertmacro _ServiceLib::Create`
!
macro _ServiceLib::Create _RETURN _NAME _PATH _TYPE _START _DEPEND
    Push 
    Push 
"start"
    
Push "${_NAME}"
    
StrCmp "${_DEPEND}" "" +3
    Push 
"path=${_PATH};servicetype=${_TYPE};starttype=${_START};"
    
Goto +2
    Push 
"path=${_PATH};servicetype=${_TYPE};starttype=${_START};depend=${_DEPEND};"
    
Call Service
    Pop 
${_RETURN}
!
macroend

;= ${ServiceLib::Start}
!
define ServiceLib::Start `!insertmacro _ServiceLib::Start`
!
macro _ServiceLib::Start _RETURN _NAME
    Push 
    Push 
"start"
    
Push "${_NAME}"
    
Push ""
    
Call Service
    Pop 
${_RETURN} ;= Returns true/false
!macroend

;= ${ServiceLib::Remove}
!
define ServiceLib::Remove `!insertmacro _ServiceLib::Remove`
!
macro _ServiceLib::Remove _RETURN _NAME
    Push 
    Push 
"delete"
    
Push "${_NAME}"
    
Push ""
    
Call Service
    Pop 
${_RETURN} ;= Returns true/false
!macroend

;= ${ServiceLib::Stop}
!
define ServiceLib::Stop `!insertmacro _ServiceLib::Stop`
!
macro _ServiceLib::Stop _RETURN _NAME
    Push 
    Push 
"stop"
    
Push "${_NAME}"
    
Push ""
    
Call Service
    Pop 
${_RETURN} ;= Returns true/false
!macroend

;= ${ServiceLib::Pause}
!
define ServiceLib::Pause `!insertmacro _ServiceLib::Pause`
!
macro _ServiceLib::Pause _RETURN _NAME
    Push 
    Push 
"pause"
    
Push "${_NAME}"
    
Push ""
    
Call Service
    Pop 
${_RETURN} ;= Returns true/false
!macroend

;= ${ServiceLib::Continue}
!
define ServiceLib::Continue `!insertmacro _ServiceLib::Continue`
!
macro _ServiceLib::Continue _RETURN _NAME
    Push 
    Push 
"continue"
    
Push "${_NAME}"
    
Push ""
    
Call Service
    Pop 
${_RETURN} ;= Returns true/false
!macroend

;= ${ServiceLib::Status}
!
define ServiceLib::Status `!insertmacro _ServiceLib::Status`
!
macro _ServiceLib::Status _RETURN _NAME
    Push 
    Push 
"status"
    
Push "${_NAME}"
    
Push ""
    
Call Service
    Pop 
${_RETURN} ;= Returns stopped/running/start_pending/stop_pending/continue_pending/pause_pending/pause/unknown
!macroend 
Also, I'd like to ask about working with dependencies. When I use my ${ServiceLib::Create} macro, how would I add dependencies? I know you're supposed to end the parameter with a semicolon (;) but there isn't anything specifing how to separate values if there are multiple dependencies needed. What's the delimiter to use to add more than just one? Is it a simple comma (,) to separate each value?

Thanks in advance! =)

Kind Regards,
demon.devin
demon.devin is offline   Reply With Quote
Old 30th September 2017, 21:23   #2
demon.devin
Junior Member
 
Join Date: Sep 2017
Posts: 3
Exclamation Disregard the Above Macros.

I've noticed that the macros I shared above are written wrong. I'm not sure if it's because of the way this forum handles code snippets but I've attached a file with the correct code for someone to review.

Thanks and sorry for the above mishap.
Attached Files
File Type: nsh Services.nsh (2.0 KB, 16 views)
demon.devin is offline   Reply With Quote
Old 1st October 2017, 00:13   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,610
Dependencies are not currently supported by that header http://forums.winamp.com/showthread.php?t=336671

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 1st October 2017, 00:58   #4
demon.devin
Junior Member
 
Join Date: Sep 2017
Posts: 3
Cool Did not know that.

Thanks. I did not know that but it doesn't matter much now. I decided to go a different route anyway as I was growing impatient. I ended up writing macros which made use of the command line. So far my first couple of test runs proved successful.

For those who are interested in what the macros are you can view the attached file I've shared. Thank you guys anyway!

Kind Regards,
demon.devin
Attached Files
File Type: nsh Services.nsh (4.1 KB, 18 views)
demon.devin is offline   Reply With Quote
Old 3rd October 2017, 22:49   #5
Nutzzz
Junior Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 18
FYI, SimpleSC works well for our service needs.
Nutzzz is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
services servicelib.nsh

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump