提取文件图标并以html显示 [英] Extracting file icon and display in html

查看:107
本文介绍了提取文件图标并以html显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人晚上,

我已经开始为我想使用电子框架编写的应用程序做一些研究。我已经弄清楚了如何向用户显示我想要的内容,除了图标。在应用程序的一部分中,用户可以键入路径,它将在该路径中列出文件,我想从文件中拉出图标,以便图标显示出来,就像在Windows文件浏览器中一样。这是我遇到障碍的地方,我正在寻找一些指导。

I have started doing some research for an application i want to write using the electron framework. I have figured out how to display what i want to the user with the exception of the icons. There is a part of the application where the user can type a path and it will list the files in that path, i would like to pull the icon from the files so its displayed just like it would be in the windows file explorer. This is where i have been running into a roadblock and I'm looking for some guidance.

nodejs中是否有一种方法可以让我提供文件路径并作为回报,我可以传递给HTML图片吗?我是nodejs的新手,所以我想我会问问是否有人知道一种简单的方法。

Is there a method in nodejs that would allow me to provide a file path and in return get a image back i can pass to HTML? Im new to nodejs so i figured i would ask and see if anyone knew of an easy way.

推荐答案

图标提取器
,您可以像这样使用它从系统中提取任何应用程序图标,但它必须是** .. exe * *文件。

There is icon-extractor you can use it like this to extract any app icon from the system , but it must be an**".exe"** file.

var iconExtractor = require('icon-extractor');
var fs = require('fs');

iconExtractor.emitter.on('icon', function(data){
console.log('Here is my context: ' + data.Context);
console.log('Here is the path it was for: ' + data.Path);
var icon = data.Base64ImageData;

fs.writeFile('img.png', icon, 'base64', (err) => {
 console.log(err);

});
});

iconExtractor.getIcon('ANY_TEXT','PAHT_TO_APP.exe');

这篇关于提取文件图标并以html显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆