package win32api import ( "errors" "syscall" "unsafe" ) /* BOOL CreateEnvironmentBlock( LPVOID *lpEnvironment, HANDLE hToken, BOOL bInherit ); */ func CreateEnvironmentBlock(lpEnvironment *HANDLE, hToken TOKEN, bInherit uintptr) error { userenv, err := syscall.LoadLibrary("userenv.dll") if err != nil { return errors.New("Can't Load Userenv API") } defer syscall.FreeLibrary(userenv) Dup, err := syscall.GetProcAddress(syscall.Handle(userenv), "CreateEnvironmentBlock") if err != nil { return errors.New("Can't Load WTSQueryUserToken API") } r, _, err := syscall.Syscall6(uintptr(Dup), 3, uintptr(unsafe.Pointer(lpEnvironment)), uintptr(hToken), bInherit, 0, 0, 0) if r == 0 { return err } return nil }