加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dmsoft.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
清风千年 提交于 2023-03-19 21:12 . 删除注释
package dmsoft
import (
"syscall"
"unsafe"
ole "github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil"
)
var (
dmReg32 = syscall.NewLazyDLL("DmReg.dll")
_SetDllPathA = dmReg32.NewProc("SetDllPathA")
_SetDllPathW = dmReg32.NewProc("SetDllPathW")
)
type Dmsoft struct {
dm *ole.IDispatch
IUnknown *ole.IUnknown
}
func NewDmsoft() *Dmsoft {
var com Dmsoft
var err error
ole.CoInitialize(0)
com.IUnknown, err = oleutil.CreateObject("dm.dmsoft")
if err != nil {
panic(err)
}
com.dm, err = com.IUnknown.QueryInterface(ole.IID_IDispatch)
if err != nil {
panic(err)
}
return &com
}
// Release 释放
func (com *Dmsoft) Release() {
com.IUnknown.Release()
com.dm.Release()
ole.CoUninitialize()
}
// SetDllPathA Ascii
func SetDllPathA(path string, mode int) bool {
var _p0 *uint16
_p0, _ = syscall.UTF16PtrFromString(path)
ret, _, _ := _SetDllPathA.Call(uintptr(unsafe.Pointer(_p0)), uintptr(mode))
return ret != 0
}
// SetDllPathW Unicode
func SetDllPathW(path string, mode int) bool {
var _p0 *uint16
_p0, _ = syscall.UTF16PtrFromString(path)
ret, _, _ := _SetDllPathW.Call(uintptr(unsafe.Pointer(_p0)), uintptr(mode))
return ret != 0
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化