我想使用nodejs访问硬件信息,如处理器ID,HDD Serial,Active LAN卡的MAC地址和其他一些信息。 通过使用Windows特定命令,我可以获得ProcessorID和HDD序列号。但是这个系统将在不同的操作系统上运行,所以我需要跨平台的解决方案来获取这些信息。
如何获取所有平台的此信息?
答案 0 :(得分:4)
This question is a bit old but it returned in my google search, so I'll share a lib that I found. I'm not sure it is good because I didn't really use it, but seems nice despite it still has no support for Windows platform: https://github.com/sebhildebrandt/systeminformation
答案 1 :(得分:2)
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
VideoSearchCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
YoutubeSearchResult *cellSearchResult = [self.ytSearchResults objectAtIndex:indexPath.row];
if (cellSearchResult.thumbnailImage.image == nil)
{
//NSLog(@"loading image");
__weak VideoSearchCell *weakCell = cell;
__weak YoutubeSearchResult *weakResult = cellSearchResult;
NSURL *url = [NSURL URLWithString:cellSearchResult.thumbUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
UIImage *placeholderImage = [UIImage imageNamed:@"your_placeholder"];
[cellSearchResult.thumbnailImage setImageWithURLRequest:request placeholderImage:placeholderImage success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image)
{
weakResult.thumbnailImage.image = image;
weakCell.imageView.image = image;
[weakCell setNeedsLayout];
} failure:nil];
} else {
if (cell.imageView.image != cellSearchResult.thumbnailImage.image)
{
cell.imageView.image = cellSearchResult.thumbnailImage.image;
}
}
return cell;
}
内置模块将提供您所需的大部分内容,并且可以跨平台兼容。
https://nodejs.org/api/os.html
使用此模块,您可以确定正在运行的平台,并使用特定于平台的命令获取您需要的其他信息。