【CoCreateInstance】panic:Not enough storage is available to process this command.
伟 马
0
信誉分
昨天我的代码中出现了这样的恐慌状况:恐慌信息:创建对象失败,错误信息为“没有足够的存储空间来执行此命令”。
我想问一下该如何解决这个问题。
【CoCreateInstance】panic:Not enough storage is available to process this command.
err := CoInitializeEx()
ensure.Null(err, "CoInitializeEx failed with error %v", err)
err = CoInitializeSecurity()
ensure.Null(err, "CoInitializeSecurity failed with error %v", err)
// create WMI Locator
locator, err := CreateObject("WbemScripting.SWbemLocator")
ensure.Null(err, "create object failed with error %v", err)
func CreateObject(programID string) (unknown *IUnknown, err error) {
go
classID, err := ClassIDFrom(programID)
if err != nil {
return
}
unknown, err = CreateInstance(classID, IIdIunknown)
if err != nil {
return
}
return
}
func CreateInstance(clsid *define.Guid, iid *define.Guid) (unk *IUnknown, err error) {
go
if iid == nil {
iid = IIdIunknown
}
hr, _, _ := procCoCreateInstance.Call(
uintptr(unsafe.Pointer(clsid)),
0,
ClsctxInprocServer,
uintptr(unsafe.Pointer(iid)),
uintptr(unsafe.Pointer(&unk)))
if hr != 0 {
err = syscall.Errno(hr)
}
return
}
There was such a panic in my code yesterday: panic: create object failed with error Not enough storage is available to process this command.
I would like to ask how to solve this problem.
Windows 开发 | Windows API - Win32
登录以回答