Golang在Linux中的syscall.NewLazyDLL函数

huangapple go评论80阅读模式
英文:

Golang syscall.NewLazyDLL in Linux

问题

有没有办法在Ubuntu中加载syscall.NewLazyDLL?

我尝试了以下代码:

GOOS=windows GOARCH=amd64 go build -ldflags "-w -s" -o myFileName *.go

但是无法找到syscall.NewLazyDLL。

var (
	mod               = syscall.NewLazyDLL("user32.dll")
	procGetWindowText = mod.NewProc("GetWindowTextW")
)

我的目标是从我的主Ubuntu操作系统加载"windows"系统调用函数,这样我就不需要切换到Windows来编写代码了。是否有办法让Ubuntu调用syscall.NewLazyDLL中的Windows函数,还是我必须在Windows中编写代码?

英文:

Is there any way to load the syscall.NewLazyDLL in Ubuntu?

I tried:

GOOS=windows GOARCH=amd64 go build -ldflags "-w -s" -o myFileName *.go

but the syscall.NewLazyDLL is not found.

var (
	mod               = syscall.NewLazyDLL("user32.dll")
	procGetWindowText = mod.NewProc("GetWindowTextW")
)

My goal is to load the "windows" syscall functions, but from my main Ubuntu OS,
so I dont need to switch to Windows to code. Is there any way Ubuntu can call the Windows functions from syscall.NewLazyDLL or do I have to write code in Windows for this?

答案1

得分: 1

当然,你需要使用Windows,因为你想要开发Windows而不是Linux,使用syscall.NewLazyDLL("user32.dll")
安装一个虚拟机。

英文:

Of course you have to be on Windows, you are wanting to develop for Windows and not Linux using syscall.NewLazyDLL("user32.dll").
Install a virtual machine.

huangapple
  • 本文由 发表于 2022年2月23日 15:55:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/71233134.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定