Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
1. add net6 and net8 project
  • Loading branch information
oven425 committed Jan 17, 2024
1 parent 871a67a commit e8205da
Show file tree
Hide file tree
Showing 7 changed files with 1,209 additions and 0 deletions.
Binary file added 48720668291_7f311e241d_o.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions ConsoleApp_NET/ConsoleApp_NET.csproj
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>
13 changes: 13 additions & 0 deletions ConsoleApp_NET/Program.cs
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();
28 changes: 28 additions & 0 deletions QSoft.DevCon.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DevMgr", "DevMgr\DevMgr.vcx
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{11F24625-421A-48D9-A33A-981F2D95537D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QSoft.DevConCore", "QSoft.DevConCore\QSoft.DevConCore.csproj", "{95F56BE7-3995-473E-A55F-EEE2A5BE498A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp_NET", "ConsoleApp_NET\ConsoleApp_NET.csproj", "{1AFBFF04-9785-4DE4-8795-627AD0C436B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -77,6 +81,30 @@ Global
{11F24625-421A-48D9-A33A-981F2D95537D}.Release|x64.Build.0 = Release|Any CPU
{11F24625-421A-48D9-A33A-981F2D95537D}.Release|x86.ActiveCfg = Release|Any CPU
{11F24625-421A-48D9-A33A-981F2D95537D}.Release|x86.Build.0 = Release|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Debug|x64.ActiveCfg = Debug|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Debug|x64.Build.0 = Debug|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Debug|x86.ActiveCfg = Debug|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Debug|x86.Build.0 = Debug|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Release|Any CPU.Build.0 = Release|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Release|x64.ActiveCfg = Release|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Release|x64.Build.0 = Release|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Release|x86.ActiveCfg = Release|Any CPU
{95F56BE7-3995-473E-A55F-EEE2A5BE498A}.Release|x86.Build.0 = Release|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Debug|x64.ActiveCfg = Debug|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Debug|x64.Build.0 = Debug|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Debug|x86.ActiveCfg = Debug|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Debug|x86.Build.0 = Debug|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Release|Any CPU.Build.0 = Release|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Release|x64.ActiveCfg = Release|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Release|x64.Build.0 = Release|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Release|x86.ActiveCfg = Release|Any CPU
{1AFBFF04-9785-4DE4-8795-627AD0C436B1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
72 changes: 72 additions & 0 deletions QSoft.DevConCore/CameraEx.cs
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
}
}
Loading

0 comments on commit e8205da

Please sign in to comment.