| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "unsafe" |
| 7 | |
| 8 | "golang.org/x/sys/windows" |
| 9 | ) |
| 10 | |
| 11 | type _ICoreWebView2FileVtbl struct { |
| 12 | _IUnknownVtbl |
| 13 | GetPath ComProc |
| 14 | } |
| 15 | |
| 16 | type ICoreWebView2File struct { |
| 17 | vtbl *_ICoreWebView2FileVtbl |
| 18 | } |
| 19 | |
| 20 | func (i *ICoreWebView2File) AddRef() uint32 { |
| 21 | ret, _, _ := i.vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 22 | |
| 23 | return uint32(ret) |
| 24 | } |
| 25 | |
| 26 | func (i *ICoreWebView2File) Release() uint32 { |
| 27 | ret, _, _ := i.vtbl.Release.Call(uintptr(unsafe.Pointer(i))) |
| 28 | |
| 29 | return uint32(ret) |
| 30 | } |
| 31 | |
| 32 | func (i *ICoreWebView2File) GetPath() (string, error) { |
| 33 | |
| 34 | var _path *uint16 |
| 35 | hr, _, _ := i.vtbl.GetPath.Call( |
| 36 | uintptr(unsafe.Pointer(i)), |
| 37 | uintptr(unsafe.Pointer(&_path)), |
| 38 | ) |
| 39 | if windows.Handle(hr) != windows.S_OK { |
| 40 | return "", windows.Errno(hr) |
| 41 | } |
| 42 | |
| 43 | path := windows.UTF16PtrToString(_path) |
| 44 | windows.CoTaskMemFree(unsafe.Pointer(_path)) |
| 45 | return path, nil |
| 46 | } |
| 47 |