当前位置: 首页>>代码示例>>C#>>正文


C# SP_DEVICE_INTERFACE_DATA类代码示例

本文整理汇总了C#中SP_DEVICE_INTERFACE_DATA的典型用法代码示例。如果您正苦于以下问题:C# SP_DEVICE_INTERFACE_DATA类的具体用法?C# SP_DEVICE_INTERFACE_DATA怎么用?C# SP_DEVICE_INTERFACE_DATA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SP_DEVICE_INTERFACE_DATA类属于命名空间,在下文中一共展示了SP_DEVICE_INTERFACE_DATA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupDiEnumDeviceInterfaces

 private static extern Boolean SetupDiEnumDeviceInterfaces(
     IntPtr hDevInfo,
     ref SP_DEVINFO_DATA devInfo,
     ref Guid interfaceClassGuid,
     UInt32 memberIndex,
     ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData
     );
开发者ID:pengxiangqi1991,项目名称:Camera-Control,代码行数:7,代码来源:SetupApi.cs

示例2: SetupDiEnumDeviceInterfaces

 internal static extern Boolean SetupDiEnumDeviceInterfaces(
     IntPtr DeviceInfoSet,
     IntPtr DeviceInfoData,
     ref System.Guid InterfaceClassGuid,
     Int32 MemberIndex,
     ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData
     );
开发者ID:hwchiu0810,项目名称:micro,代码行数:7,代码来源:setupapiDll.cs

示例3: SetupDiGetDeviceInterfaceDetail

 static extern Boolean SetupDiGetDeviceInterfaceDetail(
    IntPtr hDevInfo,
    ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData,
    ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData,
    UInt32 deviceInterfaceDetailDataSize,
    out UInt32 requiredSize,
    ref SP_DEVINFO_DATA deviceInfoData
 );
开发者ID:jedijosh920,项目名称:KeyboardAudio,代码行数:8,代码来源:KeyboardWriter.cs

示例4: SetupDiGetDeviceInterfaceDetail

        public static unsafe string SetupDiGetDeviceInterfaceDetail(
            SafeDeviceInfoSetHandle deviceInfoSet,
            SP_DEVICE_INTERFACE_DATA interfaceData,
            SP_DEVINFO_DATA* deviceInfoData)
        {
            int requiredSize;

            // First call to get the size to allocate
            SetupDiGetDeviceInterfaceDetail(
                deviceInfoSet,
                ref interfaceData,
                null,
                0,
                &requiredSize,
                deviceInfoData);

            // As we passed an empty buffer we know that the function will fail, not need to check the result.
            var lastError = GetLastError();
            if (lastError != Win32ErrorCode.ERROR_INSUFFICIENT_BUFFER)
            {
                throw new Win32Exception(lastError);
            }

            fixed (byte* pBuffer = new byte[requiredSize])
            {
                var pDetail = (SP_DEVICE_INTERFACE_DETAIL_DATA*)pBuffer;
                pDetail->cbSize = SP_DEVICE_INTERFACE_DETAIL_DATA.ReportableStructSize;

                // Second call to get the value
                var success = SetupDiGetDeviceInterfaceDetail(
                    deviceInfoSet,
                    ref interfaceData,
                    pDetail,
                    requiredSize,
                    null,
                    null);

                if (!success)
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    return null;
                }

                return SP_DEVICE_INTERFACE_DETAIL_DATA.GetDevicePath(pDetail);
            }
        }
开发者ID:jmelosegui,项目名称:pinvoke,代码行数:46,代码来源:SetupApi.Helpers.cs

示例5: GetDevicePath

        public string GetDevicePath(Guid classGuid)
        {
            IntPtr hDevInfo = IntPtr.Zero;
            try
            {
                hDevInfo = SetupDiGetClassDevs(ref classGuid, null, IntPtr.Zero, DiGetClassFlags.DIGCF_DEVICEINTERFACE | DiGetClassFlags.DIGCF_PRESENT);

                if (hDevInfo.ToInt64() <= 0)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                SP_DEVICE_INTERFACE_DATA dia = new SP_DEVICE_INTERFACE_DATA();
                dia.cbSize = (uint)Marshal.SizeOf(dia);

                SP_DEVINFO_DATA devInfo = new SP_DEVINFO_DATA();
                devInfo.cbSize = (UInt32)Marshal.SizeOf(devInfo);

                UInt32 i = 0;

                // start the enumeration
                if (!SetupDiEnumDeviceInterfaces(hDevInfo, null, ref classGuid, i, dia))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                SP_DEVICE_INTERFACE_DETAIL_DATA didd = new SP_DEVICE_INTERFACE_DETAIL_DATA();
                didd.cbSize = 4 + Marshal.SystemDefaultCharSize; // trust me :)

                UInt32 requiredSize = 0;

                if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, dia, ref didd, 256, out requiredSize, devInfo))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                return didd.DevicePath;

            }
            finally
            {
                SetupDiDestroyDeviceInfoList(hDevInfo);
            }
        }
开发者ID:bwillard,项目名称:home-integration-platform,代码行数:44,代码来源:DeviceFinder.cs

示例6: DevicePresent

        protected static bool DevicePresent(Guid g)
        {
            // Used to capture how many bytes are returned by system calls
            UInt32 theBytesReturned = 0;

            // SetupAPI32.DLL Data Structures
            SP_DEVINFO_DATA theDevInfoData = new SP_DEVINFO_DATA();
            theDevInfoData.cbSize = Marshal.SizeOf(theDevInfoData);
            IntPtr theDevInfo = SetupDiGetClassDevs(ref g, IntPtr.Zero, IntPtr.Zero, (int)(DiGetClassFlags.DIGCF_PRESENT | DiGetClassFlags.DIGCF_DEVICEINTERFACE));
            SP_DEVICE_INTERFACE_DATA theInterfaceData = new SP_DEVICE_INTERFACE_DATA();
            theInterfaceData.cbSize = Marshal.SizeOf(theInterfaceData);

            // Check for the device
            if (!SetupDiEnumDeviceInterfaces(theDevInfo, IntPtr.Zero, ref g, 0, ref theInterfaceData) && GetLastError() == ERROR_NO_MORE_ITEMS)
                return false;

            // Get the device's file path
            SetupDiGetDeviceInterfaceDetail(theDevInfo, ref theInterfaceData, IntPtr.Zero, 0, ref theBytesReturned, IntPtr.Zero);

            return !(theBytesReturned <= 0);
        }
开发者ID:ans10528,项目名称:MissionPlanner-MissionPlanner1.3.34,代码行数:21,代码来源:GenericDevice.cs

示例7: SetupDiEnumDeviceInterfaces

 public static extern bool SetupDiEnumDeviceInterfaces(DeviceInfoHandle DeviceInfoSet, int DeviceInfoData, ref System.Guid InterfaceClassGuid, int MemberIndex, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
开发者ID:GibeomGu,项目名称:flow,代码行数:1,代码来源:DeviceManagementDeclarations.cs

示例8: SetupDiGetDeviceInterfaceDetail

 static extern unsafe int SetupDiGetDeviceInterfaceDetail(
     int DeviceInfoSet,
     ref SP_DEVICE_INTERFACE_DATA lpDeviceInterfaceData,
     ref PSP_DEVICE_INTERFACE_DETAIL_DATA myPSP_DEVICE_INTERFACE_DETAIL_DATA,
     int detailSize,
     ref int requiredSize,
     int* bPtr);
开发者ID:Datenschredder,项目名称:MediaPortal-1,代码行数:7,代码来源:FutabaMDM166A.cs

示例9: CT_SetupDiEnumDeviceInterfaces

 //---#+************************************************************************
 //---NOTATION:
 //-  int CT_SetupDiEnumDeviceInterfaces(int memberIndex)
 //-
 //--- DESCRIPTION:
 //--  
 //                                                             Autor:      F.L.
 //-*************************************************************************+#*
 public unsafe int CT_SetupDiEnumDeviceInterfaces(int memberIndex)
 {
     mySP_DEVICE_INTERFACE_DATA = new SP_DEVICE_INTERFACE_DATA();
     mySP_DEVICE_INTERFACE_DATA.cbSize = Marshal.SizeOf(mySP_DEVICE_INTERFACE_DATA);
     int result = SetupDiEnumDeviceInterfaces(
         hDevInfo,
         0,
         ref  MYguid,
         memberIndex,
         ref mySP_DEVICE_INTERFACE_DATA);
     return result;
 }
开发者ID:Datenschredder,项目名称:MediaPortal-1,代码行数:20,代码来源:FutabaMDM166A.cs

示例10: SetupDiSetClassInstallParams

 protected static extern bool SetupDiSetClassInstallParams(IntPtr DeviceInfoSet,
     ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, ref SP_PROPCHANGE_PARAMS ClassInstallParams,
     int ClassInstallParamsSize);
开发者ID:CheesyKek,项目名称:ScpToolkit,代码行数:3,代码来源:ScpDevice.Interop.cs

示例11: SetupDiEnumDeviceInterfaces

 static extern unsafe int SetupDiEnumDeviceInterfaces(
     int DeviceInfoSet,
     int DeviceInfoData,
     ref  GUID lpHidGuid,
     int MemberIndex,
     ref  SP_DEVICE_INTERFACE_DATA lpDeviceInterfaceData);
开发者ID:Datenschredder,项目名称:MediaPortal-1,代码行数:6,代码来源:FutabaMDM166A.cs

示例12: findHidDevices

        /// <summary>
        /// Find all devices with the HID GUID attached to the system
        /// </summary>
        /// <remarks>This method searches for all devices that have the correct HID GUID and
        /// returns an array of matching device paths</remarks>
        private bool findHidDevices(ref String[] listOfDevicePathNames, ref int numberOfDevicesFound)
        {
            Debug.WriteLine("usbGenericHidCommunication:findHidDevices() -> Method called");
            // Detach the device if it's currently attached
            if (isDeviceAttached) detachUsbDevice();

            // Initialise the internal variables required for performing the search
            Int32 bufferSize = 0;
            IntPtr detailDataBuffer = IntPtr.Zero;
            Boolean deviceFound;
            IntPtr deviceInfoSet = new System.IntPtr();
            Boolean lastDevice = false;
            Int32 listIndex = 0;
            SP_DEVICE_INTERFACE_DATA deviceInterfaceData = new SP_DEVICE_INTERFACE_DATA();
            Boolean success;

            // Get the required GUID
            System.Guid systemHidGuid = new Guid();
            HidD_GetHidGuid(ref systemHidGuid);
            Debug.WriteLine(string.Format("usbGenericHidCommunication:findHidDevices() -> Fetched GUID for HID devices ({0})", systemHidGuid.ToString()));

            try
                {
                // Here we populate a list of plugged-in devices matching our class GUID (DIGCF_PRESENT specifies that the list
                // should only contain devices which are plugged in)
                Debug.WriteLine("usbGenericHidCommunication:findHidDevices() -> Using SetupDiGetClassDevs to get all devices with the correct GUID");
                deviceInfoSet = SetupDiGetClassDevs(ref systemHidGuid, IntPtr.Zero, IntPtr.Zero, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);

                // Reset the deviceFound flag and the memberIndex counter
                deviceFound = false;
                listIndex = 0;

                deviceInterfaceData.cbSize = Marshal.SizeOf(deviceInterfaceData);

                // Look through the retrieved list of class GUIDs looking for a match on our interface GUID
                do
                    {
                    //Debug.WriteLine("usbGenericHidCommunication:findHidDevices() -> Enumerating devices");
                    success = SetupDiEnumDeviceInterfaces
                        (deviceInfoSet,
                        IntPtr.Zero,
                        ref systemHidGuid,
                        listIndex,
                        ref deviceInterfaceData);

                    if (!success)
                        {
                        //Debug.WriteLine("usbGenericHidCommunication:findHidDevices() -> No more devices left - giving up");
                        lastDevice = true;
                        }
                    else
                        {
                        // The target device has been found, now we need to retrieve the device path so we can open
                        // the read and write handles required for USB communication

                        // First call is just to get the required buffer size for the real request
                        success = SetupDiGetDeviceInterfaceDetail
                            (deviceInfoSet,
                            ref deviceInterfaceData,
                            IntPtr.Zero,
                            0,
                            ref bufferSize,
                            IntPtr.Zero);

                        // Allocate some memory for the buffer
                        detailDataBuffer = Marshal.AllocHGlobal(bufferSize);
                        Marshal.WriteInt32(detailDataBuffer, (IntPtr.Size == 4) ? (4 + Marshal.SystemDefaultCharSize) : 8);

                        // Second call gets the detailed data buffer
                        //Debug.WriteLine("usbGenericHidCommunication:findHidDevices() -> Getting details of the device");
                        success = SetupDiGetDeviceInterfaceDetail
                            (deviceInfoSet,
                            ref deviceInterfaceData,
                            detailDataBuffer,
                            bufferSize,
                            ref bufferSize,
                            IntPtr.Zero);

                        // Skip over cbsize (4 bytes) to get the address of the devicePathName.
                        IntPtr pDevicePathName = new IntPtr(detailDataBuffer.ToInt32() + 4);

                        // Get the String containing the devicePathName.
                        listOfDevicePathNames[listIndex] = Marshal.PtrToStringAuto(pDevicePathName);

                        //Debug.WriteLine(string.Format("usbGenericHidCommunication:findHidDevices() -> Found matching device (memberIndex {0})", memberIndex));
                        deviceFound = true;
                        }
                    listIndex = listIndex + 1;
                    }
                while (!((lastDevice == true)));
                }
            catch (Exception)
                {
                // Something went badly wrong... output some debug and return false to indicated device discovery failure
                Debug.WriteLine("usbGenericHidCommunication:findHidDevices() -> EXCEPTION: Something went south whilst trying to get devices with matching GUIDs - giving up!");
//.........这里部分代码省略.........
开发者ID:hwchiu0810,项目名称:micro,代码行数:101,代码来源:deviceDiscovery.cs

示例13: GetDevicePath

        //Metodo de ayuda para encontrar la ruta al dispositivo que se busca, esta funcion es llamada desde el metodo "EncuentraDevHID"
        private string GetDevicePath(IntPtr Infoset, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
        {
            uint nRequiredSize = 0;
            //Para obtener la ruta del dispositivo se hace un proceso de dos pasos, llamar a SetupDiGetDeviceInterfaceDetail la primer vez para obtener el espacio a guardar en cSize
            //Llamar por segunda vez a la misma funcion para obtener la ruta del dispositivo.
            if (!SetupDiGetDeviceInterfaceDetail(Infoset, ref DeviceInterfaceData, IntPtr.Zero, 0, ref nRequiredSize, IntPtr.Zero))//Primera llamada
            {
                SP_DEVICE_INTERFACE_DETAIL_DATA dDetail = new SP_DEVICE_INTERFACE_DETAIL_DATA();

                if (IntPtr.Size == 8) // for 64 bit operating systems
                {
                    dDetail.cbSize = 8;
                }
                else
                {
                    dDetail.cbSize = 5; // for 32 bit systems
                }

                if (SetupDiGetDeviceInterfaceDetail(Infoset, ref DeviceInterfaceData, ref dDetail, nRequiredSize, ref nRequiredSize, IntPtr.Zero)) //Segunda llamada
                {
                    return dDetail.DevicePath;//Listo se encontro la ruta de algun dispositivo, falta ahora ver si coinciden VIP y PID
                }
                string error = Marshal.GetLastWin32Error().ToString();
            }
            return null; //No se encontro ningun otro dispositivo en la lista :(
        }
开发者ID:Leucemidus,项目名称:AccessB-Debug,代码行数:27,代码来源:AccessB_winusbapi_back.cs

示例14: SetupDiEnumDeviceInterfaces

 public static extern bool SetupDiEnumDeviceInterfaces(IntPtr hDeviceInfoSet, IntPtr DeviceInfoData, ref System.Guid InterfaceClassGuid, int MemberIndex, out SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
开发者ID:redshiftrobotics,项目名称:telemetry_Archive,代码行数:1,代码来源:WIN32.cs

示例15: SetupDiChangeState

 protected static extern bool SetupDiChangeState(IntPtr DeviceInfoSet,
     ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
开发者ID:CheesyKek,项目名称:ScpToolkit,代码行数:2,代码来源:ScpDevice.Interop.cs


注:本文中的SP_DEVICE_INTERFACE_DATA类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。