Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Go wrapper around Device Console Windows tool.

License

NotificationsYou must be signed in to change notification settings

mikerourke/go-devcon

Repository files navigation

Go Reference

Go wrapper around theWindows Device Console (devcon.exe).

go install github.com/mikerourke/go-devcon

Introduction

Here's a brief overview of DevCon taken from the Windows Hardware Developer documentation site:

DevCon (Devcon.exe), the Device Console, is a command-line tool that displays detailed information about devices on computers running Windows.You can use DevCon to enable, disable, install, configure, and remove devices.

DevCon runs on Microsoft Windows 2000 and later versions of Windows.

This package provides a handy mechanism for querying devices and performing various operations on said devices.It provides methods that map directly to thedevcon.exe commands.

Prerequisites

You'll need thedevcon.exe executable. It's not included in the package becauseRedistribution of Microsoft software without consent is usually a violation of Microsoft's End User License Agreements.

For information regarding how to get your hands ondevcon.exe, check out theMicrosoft documentation page.

There areother ways to get it, but you didn't hear it from me.

Usage

There is extensive documentation and examples available on thedocs site, but here's a quick example of how to log all the devices on the computer:

package mainimport ("fmt""github.com/mikerourke/go-devcon")funcmain() {dc:=devcon.New(`\path\to\devcon.exe`)devs,err:=dc.FindAll("=net")iferr!=nil {panic(err)    }for_,dev:=rangedevs {fmt.Printf("ID: %s, Name: %s\n",dev.ID,dev.Name)    }}

FAQ

Aren't you supposed to use thePnPUtil now?

Yes, butPnPUtil is only supported on Windows Vista and later. You can't use it on older operating systems.

Isn't this a little niche?

Yes, but one of my other projects requires me to check for the existence of a device and install a driver on Windows XP.I wrote a bunch of parsing code to get the output, so I figured why not open source it?

Will this work on Windows XP?

Yes, I'm using only using Go APIs available in version1.10.7 (or earlier?), since executables built with that version of Go still run on Windows XP.It's possible that earlier versionsmay work, but I used1.10.7 during development, so I'd advise sticking with that version.To target Windows XP 32-bit, build your project like so:

GOOS=windows GOARCH=386 go1.10.7 build -o myproject.exe myproject.go

[8]ページ先頭

©2009-2025 Movatter.jp