Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
public const UInt32 SPI_GETPLATFORMTYPE = 257;
[DllImport("coredll")]
public extern static Boolean SystemParametersInfo(
UInt32 uiAction,
UInt32 uiParam,
StringBuilder pvParam,
UInt32 fWinIni);
public static String GetPlatformType()
{
StringBuilder sb = new StringBuilder(255);
if(Environment.OSVersion.Platform == PlatformID.Win32NT)
return "WIN32";//NativeMethods.SystemParametersInfoWin32(NativeMethods.SPI_GETPLATFORMTYPE, (UInt32)sb.Capacity, sb, 0);
else
NativeMethods.SystemParametersInfo(NativeMethods.SPI_GETPLATFORMTYPE, (UInt32)sb.Capacity, sb, 0);
String platType = sb.ToString();
switch(platType)
{
case "PocketPC":
return "PPC";
case "Windows CE":
return "WCE";
case "Phoenix"://Casio IT-600
return "Phoenix";
default:
return platType;
}
}
[DllImport("Coredll")]
public extern static Boolean QueryInstructionSet(
UInt32 dwInstructionSet,
out CpuInstructionSet CurrentInstructionSet
);
public enum CpuInstructionSet
{
X86 = Constant.Processor.PROCESSOR_X86_32BIT_INSTRUCTION,
SH3 = Constant.Processor.PROCESSOR_HITACHI_SH3_INSTRUCTION,
SH4 = Constant.Processor.PROCESSOR_HITACHI_SH4_INSTRUCTION,
MIPSV4 = Constant.Processor.PROCESSOR_MIPS_MIPSIV_INSTRUCTION,
MIPSV4_FP = Constant.Processor.PROCESSOR_MIPS_MIPSIVFP_INSTRUCTION,
MIPSVII = Constant.Processor.PROCESSOR_MIPS_MIPSII_INSTRUCTION,
MIPSVII_FP = Constant.Processor.PROCESSOR_MIPS_MIPSIIFP_INSTRUCTION,
MIPS16 = Constant.Processor.PROCESSOR_MIPS_MIPS16_INSTRUCTION,
ARMV4 = Constant.Processor.PROCESSOR_ARM_V4_INSTRUCTION,
ARMV4T = Constant.Processor.PROCESSOR_ARM_V4T_INSTRUCTION,
ARMV4I =Constant.Processor.PROCESSOR_ARM_V4I_INSTRUCTION,
ARMV4FP = Constant.Processor.PROCESSOR_ARM_V4FP_INSTRUCTION,
ARMV4IFP = Constant.Processor.PROCESSOR_ARM_V4IFP_INSTRUCTION,
ARMV4TFP = Constant.Processor.PROCESSOR_ARM_V4TFP_INSTRUCTION,
}
internal struct SYSTEM_INFO
{
public UInt16 wProcessorArchitecture;
public UInt16 wReserved;
public UInt32 dwPageSize;
public Int32 lpMinimumApplicationAddress;
public Int32 lpMaximumApplicationAddress;
public UInt32 dwActiveProcessorMask;
public UInt32 dwNumberOfProcessors;
public UInt32 dwProcessorType;
public UInt32 dwAllocationGranularity;
public UInt16 wProcessorLevel;
public UInt16 wProcessorRevision;
}
[DllImport("Coredll")]
public extern static void GetSystemInfo(ref SYSTEM_INFO SystemInfo);
[DllImport("Kernel32.dll", EntryPoint = "GetSystemInfo")]
public extern static void GetSystemInfoWin32(ref SYSTEM_INFO SystemInfo);
public static String GetInstructionSet()
{
CpuInstructionSet iset = CpuInstructionSet.X86;
try
{
if(Environment.OSVersion.Platform == PlatformID.Win32NT)
return iset.ToString();
else
NativeMethods.QueryInstructionSet(0, out iset);
}
catch(MissingMethodException)
{
SYSTEM_INFO si = new SYSTEM_INFO();
if(Environment.OSVersion.Platform == PlatformID.Win32NT)
NativeMethods.GetSystemInfoWin32(ref si);
else
NativeMethods.GetSystemInfo(ref si);
switch(si.wProcessorArchitecture)
{
case Constant.Processor.Architecture.PROCESSOR_ARCHITECTURE_ARM:
return CpuInstructionSet.ARMV4.ToString();
case Constant.Processor.Architecture.PROCESSOR_ARCHITECTURE_SHX:
return CpuInstructionSet.SH3.ToString();
case Constant.Processor.Architecture.PROCESSOR_ARCHITECTURE_INTEL:
return CpuInstructionSet.X86.ToString();
case Constant.Processor.Architecture.PROCESSOR_ARCHITECTURE_MIPS:
return CpuInstructionSet.MIPSV4.ToString();
default:
return "Unkown_"+si.wProcessorArchitecture.ToString();
}
}
return iset.ToString();
}
Пишем под ТСД. Подключение сканера штрихкода, как компонент формы