79 Star 314 Fork 51

不在乎y/govcl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 876 Bytes
一键复制 编辑 原始数据 按行查看 历史
不在乎y 提交于 2020-06-08 11:42 . Examples are categorized by platform
// +build windows
package main
import (
"fmt"
"github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil"
_ "github.com/ying32/govcl/pkgs/winappres"
"github.com/ying32/govcl/vcl"
)
type TMainForm struct {
*vcl.TForm
Btn1 *vcl.TButton
}
var mainForm *TMainForm
func (f *TMainForm) OnFormCreate(object vcl.IObject) {
f.SetCaption("WinOLE")
f.ScreenCenter()
f.Btn1 = vcl.NewButton(f)
f.Btn1.SetParent(f)
f.Btn1.SetBounds(10, 10, 100, 30)
f.Btn1.SetCaption("打开记事本")
f.Btn1.SetOnClick(f.OnBtn1Click)
}
func (f *TMainForm) OnBtn1Click(object vcl.IObject) {
ole.CoInitializeEx(0, 0)
defer ole.CoUninitialize()
unknown, err := oleutil.CreateObject("WScript.Shell")
if err != nil {
fmt.Println(err)
return
}
shell, _ := unknown.QueryInterface(ole.IID_IDispatch)
shell.CallMethod("Run", "notepad")
}
func main() {
vcl.RunApp(&mainForm)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ying32/govcl.git
git@gitee.com:ying32/govcl.git
ying32
govcl
govcl
v2.2.0

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385