Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
1. add isconnect function for test
2. modify some method name, remove get prefix when readonly property
  • Loading branch information
oven425 committed Jul 10, 2024
1 parent dec0907 commit 578cc1b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions ConsoleApp_NET472/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ static void Main(string[] args)
}).ToList();
foreach (var oo in "Camera".Devices())
{
var firstinstalldate = oo.GetFirstInstallDate();
var firstinstalldate = oo.FirstInstallDate();
var isconnected= oo.IsConnected();
var panel = oo.Panel();
var siblings = oo.Siblings();
var driverprovider = oo.GetDriverProvider();
var problemcode = oo.GetProblemCode();
var infsection = oo.GetDriverInfSection();
var driverprovider = oo.DriverProvider();
var problemcode = oo.ProblemCode();
var infsection = oo.DriverInfSection();
var friendname = oo.GetFriendName();
//oo.SetFriendName($"USB2.0 HD UVC WebCam");
}
Expand All @@ -50,7 +50,7 @@ static void Main(string[] args)
desc = x.GetDeviceDesc(),
class_name = x.GetClassGuid().GetClassDesc(),
drive_version = x.GetDriverVersion(),
driver_inf = x.GetDriverInfSection(),
driver_inf = x.DriverInfSection(),
driver_date = x.GetDriverDate(),
});

Expand Down
17 changes: 7 additions & 10 deletions QSoft.DevCon/DevMgrExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ public static string GetPhysicalDeviceObjectName(this (IntPtr dev, SP_DEVINFO_DA

public static string GetPowerRelations(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetString(DPKEY_Device_PowerRelations);
public static int GetProblemCode(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetInt32(DEVPKEY_Device_Device_ProblemCode);
public static int ProblemCode(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetInt32(DEVPKEY_Device_ProblemCode);

public static bool IsConnected(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
{
Expand Down Expand Up @@ -334,7 +334,6 @@ static int GetInt32(this (IntPtr dev, SP_DEVINFO_DATA devdata) src, DEVPROPKEY d
SetupDiGetDeviceProperty(src.dev, ref src.devdata, ref devkey, out property_type, mem.Pointer, reqsize, out reqsize, 0);
str = Marshal.ReadInt32(mem.Pointer);
}
var err = Marshal.GetLastWin32Error();
return str;
}

Expand Down Expand Up @@ -379,18 +378,16 @@ static void SetString(this (IntPtr dev, SP_DEVINFO_DATA devdata) src, string dat
public static string GetDriverVersion(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetString(DEVPKEY_Device_DriverVersion);

public static string GetDriverInfSection(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
{
return src.GetString(DEVPKEY_Device_DriverInfSection);
}
public static string DriverInfSection(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetString(DEVPKEY_Device_DriverInfSection);

public static DateTime GetDriverDate(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetDateTime(DEVPKEY_Device_DriverDate);

public static string GetDriverProvider(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
public static string DriverProvider(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetString(DEVPKEY_Device_DriverProvider);

public static DateTime GetFirstInstallDate(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
public static DateTime FirstInstallDate(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
=> src.GetDateTime(DEVPKEY_Device_FirstInstallDate);

public static List<string> Siblings(this (IntPtr dev, SP_DEVINFO_DATA devdata) src)
Expand Down Expand Up @@ -579,7 +576,7 @@ public DEVPROPKEY(uint l, ushort w1, ushort w2, byte b1, byte b2, byte b3, byte
readonly internal static DEVPROPKEY DEVPKEY_Device_DriverInfSection = new() { fmtid = Guid.Parse("{a8b865dd-2e3d-4094-ad97-e593a70c75d6}"), pid = 6 };
readonly internal static DEVPROPKEY DEVPKEY_Device_DriverProvider = new() { fmtid = Guid.Parse("{a8b865dd-2e3d-4094-ad97-e593a70c75d6}"), pid = 9 };
readonly internal static DEVPROPKEY DEVPKEY_Device_Siblings = new() { fmtid = Guid.Parse("{4340a6c5-93fa-4706-972c-7b648008a5a7}"), pid = 10 };
readonly internal static DEVPROPKEY DEVPKEY_Device_Device_ProblemCode = new() { fmtid=Guid.Parse("{4340a6c5-93fa-4706-972c-7b648008a5a7}"), pid=3 };
readonly internal static DEVPROPKEY DEVPKEY_Device_ProblemCode = new() { fmtid=Guid.Parse("{4340a6c5-93fa-4706-972c-7b648008a5a7}"), pid=3 };
readonly internal static DEVPROPKEY DEVPKEY_Device_FirstInstallDate = new DEVPROPKEY(0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29, 101); // DEVPROP_TYPE_FILETIME


Expand Down
9 changes: 7 additions & 2 deletions QSoft.DevCon/QSoft.DevCon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Copyright>Copyright © Ben Hsu 2022</Copyright>
<Description>easy get device manager info</Description>
<PackageReleaseNotes>1. change support platform, only windows
2. new setfriendname function, require admin</PackageReleaseNotes>
<PackageReleaseNotes>1. Add get DriverInfSection
2. Add get FirstInstallDate
3. Add get DriverProvider
4. Add get ProblemCodec
5. Add get Siblings
6. Add get IsConnected for test
7. change assembly naming rule, hope multi versions in same solution</PackageReleaseNotes>
<PlatformTarget>AnyCPU</PlatformTarget>
<PackageId>$(MSBuildProjectName)</PackageId>
<Authors>$(MSBuildProjectName)</Authors>
Expand Down

0 comments on commit 578cc1b

Please sign in to comment.