GithubHelp home page GithubHelp logo

Comments (4)

ying32 avatar ying32 commented on June 6, 2024

没研究过,不过windows下可以通过注册表获取扩展名的图标,这种百度找找应该有的

from govcl.

278333422 avatar 278333422 commented on June 6, 2024

能帮忙看一下最后那几行关于 win.SHGetFileInfo和win.TSHFileInfo 哪里有问题吗 谢谢 研究一天了没有搞定

func (f *TForm1) walkFile(node *vcl.TTreeNode, path string, recurse bool) {
	fd, err := os.Open(path)
	if err != nil {
		if os.IsNotExist(err) {
			return
		}
		return
	}
	defer fd.Close()

	// 添加当前目录
	if recurse && (node == nil) {
		subNode := f.TreeView1.Items().Add(nil, ".")
		f.paths[subNode.Instance()] = path
		subNode.SetSelectedIndex(1)
		subNode.SetStateIndex(0)
	}
	//imgList := vcl.NewImageList(f)
	ico := vcl.NewIcon()
	ico.SetTransparent(true)
	ImageList1 := vcl.NewImageList(f)
	ImageList1.SetHeight(16)
	ImageList1.SetWidth(16)
	f.ListView1.SetSmallImages(ImageList1)
	defer ico.Free()
	for {
		files, err := fd.Readdir(100)
		for _, file := range files {
			if recurse {
				if file.IsDir() {
					curPath := path + string(os.PathSeparator) + file.Name()

					var subNode *vcl.TTreeNode
					if node == nil {
						subNode = f.TreeView1.Items().Add(nil, file.Name())
					} else {
						subNode = f.TreeView1.Items().AddChild(node, file.Name())
					}

					//subNode.SetImageIndex(0)
					subNode.SetSelectedIndex(1)
					subNode.SetStateIndex(0)

					//subNode.SetData(unsafe.Pointer(uintptr(index)))
					f.paths[subNode.Instance()] = curPath
					f.walkFile(subNode, curPath, recurse)
					subNode.Expand(false)

				}
			} else {
				var shfi win.TSHFileInfo
				win.SHGetFileInfo(path+ string(os.PathSeparator) + file.Name(),0,&shfi,win.SHGFI_SYSICONINDEX|win.SHGFI_SMALLICON|win.SHGFI_PIDL)
				ico.SetHandle(shfi.HIcon)
				index := ImageList1.AddIcon(ico)
				item := f.ListView1.Items().Add()
				item.SetImageIndex(index)
				item.SetCaption(file.Name())
				item.SubItems().Add(fmt.Sprintf("%d byte", file.Size()))
				item.SubItems().Add(filepath.Ext(file.Name()))
			}
		}
		if err == io.EOF {
			break
		}
		if len(files) == 0 {
			break
		}
	}
}

from govcl.

278333422 avatar 278333422 commented on June 6, 2024

@ying32
shell32dll.go
这个文件的 79行是不是少一个参数?

r, _, _ := _SHGetFileInfo.Call(CStr(pszPath), uintptr(dwFileAttributes), uintptr(unsafe.Pointer(psfi)), uintptr(uFlags))

应该为

r, _, _ := _SHGetFileInfo.Call(CStr(pszPath), uintptr(dwFileAttributes), uintptr(unsafe.Pointer(psfi)),uintptr(unsafe.Sizeof(*psfi)), uintptr(uFlags))

from govcl.

ying32 avatar ying32 commented on June 6, 2024

确实是少个 cbFileInfo

from govcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.