当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.NewLazyDLL函数代码示例

本文整理汇总了Golang中syscall.NewLazyDLL函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLazyDLL函数的具体用法?Golang NewLazyDLL怎么用?Golang NewLazyDLL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewLazyDLL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: HideConsole

func HideConsole() {
	getConsoleWindow := syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow")
	showWindow := syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow")
	if getConsoleWindow.Find() == nil && showWindow.Find() == nil {
		hwnd, _, _ := getConsoleWindow.Call()
		if hwnd != 0 {
			showWindow.Call(hwnd, 0)
		}
	}
}
开发者ID:qbit,项目名称:syncthing,代码行数:10,代码来源:hidden_windows.go

示例2: ChangeConsoleVisibility

// ChangeConsoleVisibility Change console visibility
func ChangeConsoleVisibility(visibility bool) {
	var getConsoleWindows = syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow")
	var showWindow = syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow")
	if hwnd, _, _ := showWindow.Call(); hwnd != 0 {
		if visibility {
			sw.Call(hwnd, syscall.SW_RESTORE)
		} else {
			sw.Call(hwnd, syscall.SW_HIDE)
		}
	}
}
开发者ID:yazver,项目名称:throughbox,代码行数:12,代码来源:console_windows.go

示例3: getch

func getch() byte {
	modkernel32 := syscall.NewLazyDLL("kernel32.dll")
	procReadConsole := modkernel32.NewProc("ReadConsoleW")
	procGetConsoleMode := modkernel32.NewProc("GetConsoleMode")
	procSetConsoleMode := modkernel32.NewProc("SetConsoleMode")

	var mode uint32
	pMode := &mode
	procGetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(unsafe.Pointer(pMode)))

	var echoMode, lineMode uint32
	echoMode = 4
	lineMode = 2
	var newMode uint32
	newMode = mode ^ (echoMode | lineMode)

	procSetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(newMode))

	line := make([]uint16, 1)
	pLine := &line[0]
	var n uint16
	procReadConsole.Call(uintptr(syscall.Stdin), uintptr(unsafe.Pointer(pLine)), uintptr(len(line)), uintptr(unsafe.Pointer(&n)))

	// For some reason n returned seems to big by 2 (Null terminated maybe?)
	if n > 2 {
		n -= 2
	}

	b := []byte(string(utf16.Decode(line[:n])))

	procSetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(mode))

	return b[0]
}
开发者ID:jingweno,项目名称:gopass,代码行数:34,代码来源:win.go

示例4: CloseTCPEntry

func CloseTCPEntry(row *MIB_TCPROW2) error {
	row.dwState = 12
	if err, _, _ := syscall.NewLazyDLL("Iphlpapi.dll").NewProc("SetTcpEntry").Call(uintptr(unsafe.Pointer(row))); err != 0 {
		return syscall.Errno(err)
	}
	return nil
}
开发者ID:tinycedar,项目名称:lily,代码行数:7,代码来源:sys_tcptable.go

示例5: getch

func getch() byte {
	modkernel32 := syscall.NewLazyDLL("kernel32.dll")
	procReadConsole := modkernel32.NewProc("ReadConsoleW")
	procGetConsoleMode := modkernel32.NewProc("GetConsoleMode")
	procSetConsoleMode := modkernel32.NewProc("SetConsoleMode")

	var mode uint32
	pMode := &mode
	procGetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(unsafe.Pointer(pMode)))

	var echoMode, lineMode uint32
	echoMode = 4
	lineMode = 2
	var newMode uint32
	newMode = mode ^ (echoMode | lineMode)

	procSetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(newMode))

	line := make([]uint16, 1)
	pLine := &line[0]
	var n uint16
	procReadConsole.Call(uintptr(syscall.Stdin), uintptr(unsafe.Pointer(pLine)), uintptr(len(line)), uintptr(unsafe.Pointer(&n)))

	b := []byte(string(utf16.Decode(line)))

	procSetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(mode))

	if len(b) > 0 {
		return b[0]
	} else {
		return 13
	}
}
开发者ID:jjz,项目名称:ztodo,代码行数:33,代码来源:win.go

示例6: getch

func getch() (byte, error) {
	modkernel32 := syscall.NewLazyDLL("kernel32.dll")
	procReadConsole := modkernel32.NewProc("ReadConsoleW")
	procGetConsoleMode := modkernel32.NewProc("GetConsoleMode")
	procSetConsoleMode := modkernel32.NewProc("SetConsoleMode")

	var mode uint32
	pMode := &mode
	procGetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(unsafe.Pointer(pMode)))

	var echoMode, lineMode uint32
	echoMode = 4
	lineMode = 2
	var newMode uint32
	newMode = mode &^ (echoMode | lineMode)

	procSetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(newMode))
	defer procSetConsoleMode.Call(uintptr(syscall.Stdin), uintptr(mode))

	line := make([]uint16, 1)
	pLine := &line[0]
	var n uint16
	procReadConsole.Call(uintptr(syscall.Stdin), uintptr(unsafe.Pointer(pLine)), uintptr(len(line)), uintptr(unsafe.Pointer(&n)))

	b := []byte(string(utf16.Decode(line)))

	// Not sure how this could happen, but it did for someone
	if len(b) > 0 {
		return b[0], nil
	} else {
		return 13, errors.New("Read error")
	}
}
开发者ID:Machyne,项目名称:mongo,代码行数:33,代码来源:win.go

示例7: main

/* Declare imported function so that we can actually use it. */
func main() {
	addbasic := syscall.NewLazyDLL("add_basic.dll")
	procAdd := addbasic.NewProc("Add")
	val, _, _ := procAdd.Call(6, 23)

	fmt.Println(val)
}
开发者ID:Xackery,项目名称:w32,代码行数:8,代码来源:addtest_basic.go

示例8: isRunning

func isRunning() bool {

	kernel32 := syscall.NewLazyDLL("kernel32.dll")
	CreateToolhelp32Snapshot := kernel32.NewProc("CreateToolhelp32Snapshot")
	pHandle, _, _ := CreateToolhelp32Snapshot.Call(uintptr(0x2), uintptr(0x0))
	if int(pHandle) == -1 {
		return false
	}
	Process32Next := kernel32.NewProc("Process32Next")
	run := false
	for {
		var proc PROCESSENTRY32
		proc.dwSize = ulong(unsafe.Sizeof(proc))
		if rt, _, _ := Process32Next.Call(uintptr(pHandle), uintptr(unsafe.Pointer(&proc))); int(rt) == 1 {
			pName := string(proc.szExeFile[0:])
			if compareProcess != "" && pName[0:len(compareProcess)] == compareProcess {
				run = true
			}
			//fmt.Println("ProcessName : ",pName+"sssschrome.exe","j");
			//fmt.Println("ProcessID : "+strconv.Itoa(int(proc.th32ProcessID)));
		} else {
			break
		}
	}
	CloseHandle := kernel32.NewProc("CloseHandle")
	_, _, _ = CloseHandle.Call(pHandle)
	return run
}
开发者ID:cccqcn,项目名称:go,代码行数:28,代码来源:main.go

示例9: TestAtomicMmap

func TestAtomicMmap(t *testing.T) {
	// Test that atomic operations work on "external" memory. Previously they crashed (#16206).
	// Also do a sanity correctness check: under race detector atomic operations
	// are implemented inside of race runtime.
	kernel32 := syscall.NewLazyDLL("kernel32.dll")
	VirtualAlloc := kernel32.NewProc("VirtualAlloc")
	VirtualFree := kernel32.NewProc("VirtualFree")
	const (
		MEM_COMMIT     = 0x00001000
		MEM_RESERVE    = 0x00002000
		MEM_RELEASE    = 0x8000
		PAGE_READWRITE = 0x04
	)
	mem, _, err := syscall.Syscall6(VirtualAlloc.Addr(), 4, 0, 1<<20, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE, 0, 0)
	if err != 0 {
		t.Fatalf("VirtualAlloc failed: %v", err)
	}
	defer syscall.Syscall(VirtualFree.Addr(), 3, mem, 1<<20, MEM_RELEASE)
	a := (*uint64)(unsafe.Pointer(mem))
	if *a != 0 {
		t.Fatalf("bad atomic value: %v, want 0", *a)
	}
	atomic.AddUint64(a, 1)
	if *a != 1 {
		t.Fatalf("bad atomic value: %v, want 1", *a)
	}
	atomic.AddUint64(a, 1)
	if *a != 2 {
		t.Fatalf("bad atomic value: %v, want 2", *a)
	}
}
开发者ID:2thetop,项目名称:go,代码行数:31,代码来源:race_windows_test.go

示例10: HideConsole

// Hide console on windows without removing it unlike -H windowsgui.
func HideConsole(hide bool) {
	var k32 = syscall.NewLazyDLL("kernel32.dll")
	var cw = k32.NewProc("GetConsoleWindow")
	var u32 = syscall.NewLazyDLL("user32.dll")
	var sw = u32.NewProc("ShowWindow")
	hwnd, _, _ := cw.Call()
	if hwnd == 0 {
		return
	}
	if hide {
		var SW_HIDE uintptr = 0
		sw.Call(hwnd, SW_HIDE)
	} else {
		var SW_RESTORE uintptr = 9
		sw.Call(hwnd, SW_RESTORE)
	}
}
开发者ID:pkdevboxy,项目名称:query,代码行数:18,代码来源:platform_windows.go

示例11: init

func init() {
	hapi := syscall.NewLazyDLL("Wlanapi.dll")
	hWlanOpenHandle = hapi.NewProc("WlanOpenHandle")
	hWlanCloseHandle = hapi.NewProc("WlanCloseHandle")
	hWlanEnumInterfaces = hapi.NewProc("WlanEnumInterfaces")
	hWlanGetAvailableNetworkList = hapi.NewProc("WlanGetAvailableNetworkList")
	hWlanGetNetworkBssList = hapi.NewProc("WlanGetNetworkBssList")
	hWlanFreeMemory = hapi.NewProc("WlanFreeMemory")
}
开发者ID:WoLfh0UnD,项目名称:WiFiMon,代码行数:9,代码来源:api.go

示例12: initialize

func initialize() {

	secur32dll := syscall.NewLazyDLL("secur32.dll")
	initSecurityInterface := secur32dll.NewProc("InitSecurityInterfaceW")

	ptr, _, _ := initSecurityInterface.Call()
	sec_fn = (*SecurityFunctionTable)(unsafe.Pointer(ptr))

	initialized = true
}
开发者ID:nicollet,项目名称:bosun,代码行数:10,代码来源:ntlm_windows.go

示例13: setColorTemp

// setColorTemp changes the device gamma curve colors to reflect the specified color temperature.
func setColorTemp(gammar, gammag, gammab float64) {
	user32 := syscall.NewLazyDLL("User32.dll")
	gdi32 := syscall.NewLazyDLL("Gdi32.dll")
	procGetDC := user32.NewProc("GetDC")
	procSetDeviceGammaRamp := gdi32.NewProc("SetDeviceGammaRamp")

	var gamma [3][256]uint16

	for i := 0; i < 256; i++ {
		g := 65535.0 * float64(i) / float64(256)
		gamma[0][i] = uint16(g * gammar)
		gamma[1][i] = uint16(g * gammag)
		gamma[2][i] = uint16(g * gammab)
	}

	hdc, _, _ := procGetDC.Call(uintptr(0))

	procSetDeviceGammaRamp.Call(hdc, uintptr(unsafe.Pointer(&gamma)))
}
开发者ID:howeyc,项目名称:go-sct,代码行数:20,代码来源:sct_windows.go

示例14: callEXEByShell

/**call exe*/
func callEXEByShell(path string) {
	var hand uintptr = uintptr(0)
	var operator uintptr = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("open")))
	var fpath uintptr = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path)))
	var param uintptr = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("/S")))
	var dirpath uintptr = uintptr(0)
	var ncmd uintptr = uintptr(1)
	shell32 := syscall.NewLazyDLL("shell32.dll")
	ShellExecuteW := shell32.NewProc("ShellExecuteW")
	_, _, _ = ShellExecuteW.Call(hand, operator, fpath, param, dirpath, ncmd)
}
开发者ID:dcmsy,项目名称:datapost,代码行数:12,代码来源:datapost_upgrade.go

示例15: MessageBox

func MessageBox(title, text string) int {
	var mod = syscall.NewLazyDLL("user32.dll")
	var proc = mod.NewProc("MessageBoxW")
	var MB_YESNO = 0x00000004

	ret, _, _ := proc.Call(0,
		uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),
		uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),
		uintptr(MB_YESNO))
	return int(ret)
}
开发者ID:arduino,项目名称:arduino-create-agent,代码行数:11,代码来源:hidefile_windows.go


注:本文中的syscall.NewLazyDLL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。