-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. add net6 and net8 project
- Loading branch information
Showing
7 changed files
with
1,209 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishAot>true</PublishAot> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\QSoft.DevConCore\QSoft.DevConCore.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
using QSoft.DevCon; | ||
Console.WriteLine("Hello, World!"); | ||
var cameras = "Camera".Devices() | ||
.Select(x => new {name=x.GetDescription(), locationpaths=x.GetLocationPaths(), panel= x.Panel() }); | ||
foreach (var cam in cameras) | ||
{ | ||
Console.WriteLine($"name:{cam.name}"); | ||
Console.WriteLine($"locationpaths:{cam.locationpaths}"); | ||
Console.WriteLine($"panel:{cam.panel}"); | ||
} | ||
|
||
Console.ReadLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using static QSoft.DevCon.SetupApi; | ||
|
||
namespace QSoft.DevCon | ||
{ | ||
//https://learn.microsoft.com/zh-tw/windows-hardware/drivers/install/devpkey-device-physicaldevicelocation | ||
//https://learn.microsoft.com/zh-tw/windows-hardware/drivers/stream/camera-device-orientation | ||
public static partial class DevMgrExtension | ||
{ | ||
public static DEVPROPKEY DEVPKEY_Devices_PhysicalDeviceLocation = new DEVPROPKEY() { fmtid = Guid.Parse("{540B947E-8B40-45BC-A8A2-6A0B894CBDA2}"), pid = 9 }; | ||
public static CameraPanel Panel(this (IntPtr dev, SetupApi.SP_DEVINFO_DATA devdata) src) | ||
{ | ||
uint propertytype = 0; | ||
|
||
int reqsz = 0; | ||
var hr = SetupApi.SetupDiGetDeviceProperty(src.dev, ref src.devdata, ref DEVPKEY_Devices_PhysicalDeviceLocation, out propertytype, null, 0, out reqsz, 0); | ||
if (hr == false) | ||
{ | ||
var err = Marshal.GetLastWin32Error(); | ||
} | ||
var buffer = Marshal.AllocHGlobal((int)reqsz); | ||
hr = SetupApi.SetupDiGetDeviceProperty(src.dev, ref src.devdata, ref DEVPKEY_Devices_PhysicalDeviceLocation, out propertytype, buffer, reqsz, out reqsz, 0); | ||
byte[] lbuffer = new byte[reqsz]; | ||
Marshal.Copy(buffer, lbuffer, 0, (int)reqsz); | ||
|
||
|
||
BitArray myBA3 = new BitArray(lbuffer); | ||
|
||
Convert(myBA3.Get(69), myBA3.Get(68), myBA3.Get(67)); | ||
|
||
int errcode = Marshal.GetLastWin32Error(); | ||
Marshal.FreeHGlobal(buffer); | ||
|
||
return (CameraPanel)Convert(myBA3.Get(69), myBA3.Get(68), myBA3.Get(67)); | ||
} | ||
|
||
static int Convert(params bool[] src) | ||
{ | ||
int dd = 0; | ||
for (int i = 0; i < src.Length; i++) | ||
{ | ||
|
||
if (i > 0) | ||
{ | ||
dd = dd << 1; | ||
} | ||
int o = src[i] == true ? 1 : 0; | ||
dd = dd | o; | ||
|
||
|
||
} | ||
return dd; | ||
} | ||
} | ||
|
||
public enum CameraPanel | ||
{ | ||
Top, | ||
Bottom, | ||
Left, | ||
Right, | ||
Front, | ||
Back, | ||
Unknow | ||
} | ||
} |
Oops, something went wrong.