Skip to content

Commit

Permalink
load dll when call New
Browse files Browse the repository at this point in the history
  • Loading branch information
nb857 committed Dec 1, 2021
1 parent 4b2a422 commit 9ee50fe
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

var (
dmReg32 = syscall.NewLazyDLL("DmReg.dll")
procSetDllPathA = dmReg32.NewProc("SetDllPathA")
procSetDllPathW = dmReg32.NewProc("SetDllPathW")
dmReg32 *syscall.LazyDLL
procSetDllPathA *syscall.LazyProc
procSetDllPathW *syscall.LazyProc
)

// DmSoft ...
Expand All @@ -23,12 +23,12 @@ type DmSoft struct {
IUnknown *ole.IUnknown
}

func SetDLLPath(path string) {
dmReg32 = syscall.NewLazyDLL(path + "DmReg.dll")
}

// New return *DmSoft.DmSoft
func New() (dm *DmSoft, err error) {
func New(dmRegDllPath string) (dm *DmSoft, err error) {
dmReg32 = syscall.NewLazyDLL(dmRegDllPath + "DmReg.dll")
procSetDllPathA = dmReg32.NewProc("SetDllPathA")
procSetDllPathW = dmReg32.NewProc("SetDllPathW")

var com DmSoft
// 创建对象
ole.CoInitialize(0)
Expand Down

0 comments on commit 9ee50fe

Please sign in to comment.