RunningAs added
1 parent 01c1131 commit ad4b4876fc91280006743383ecf2c6ad29c2020b
root authored on 2 Feb 2022
Showing 2 changed files
View
4
README.md
 
**<u>WindowsShortcutFull</u>**
 
view, modify and create windows shortcut files (.lnk)
 
**<u>RunningAs</u>**
 
Alert box containing current user process running as
View
42
RunningAs-Example.go 0 → 100644
/***
* Just a small demonstration script that makes an alert box containing the user the current process is running as
*/
package main
 
import (
"log"
"os/user"
"syscall"
"unsafe"
)
 
// MessageBox of Win32 API.
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
ret, _, _ := syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),
uintptr(flags))
 
return int(ret)
}
 
// MessageBoxPlain of Win32 API.
func MessageBoxPlain(title, caption string) int {
const (
NULL = 0
MB_OK = 0
)
return MessageBox(NULL, caption, title, MB_OK)
}
 
func main() {
currentUser, err := user.Current()
if err != nil {
log.Fatalf("Unable to get current user: %s", err)
}
userId := currentUser.Username
 
MessageBoxPlain("Running as", userId)
}
Buy Me A Coffee