From 0056a725960a147bfa235e380a7df41a8208f42b Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Fri, 11 May 2012 01:29:06 -0700 Subject: [PATCH] Add GetExePath func. --- service.go | 7 +++++++ service_windows.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/service.go b/service.go index e80b051..f4fee70 100644 --- a/service.go +++ b/service.go @@ -34,3 +34,10 @@ type Service interface { LogWarning(format string, a ...interface{}) error LogInfo(format string, a ...interface{}) error } + +// Returns the full path of the running executable +// as reported by the system. Includes the executable +// image name. +func GetExePath() (exePath string, err error) { + return getExePath() +} diff --git a/service_windows.go b/service_windows.go index 6f40a16..cc2c010 100644 --- a/service_windows.go +++ b/service_windows.go @@ -104,6 +104,10 @@ func (ws *windowsService) LogInfo(format string, a ...interface{}) error { return writeToEventLog(ws.name, fmt.Sprintf(format, a ...), levelInfo) } +func getExePath() (exePath string, err error) { + return getModuleFileName() +} + var ( advapi = syscall.MustLoadDLL("advapi32.dll") kernel = syscall.MustLoadDLL("kernel32.dll")