|    
			
				19/01/2010, 15:57
			
			
			  | 
  |   |  |  |  Fecha de Ingreso: marzo-2008 
						Mensajes: 37
					 Antigüedad: 17 años, 7 meses Puntos: 0 |  | 
  |  Respuesta: Obtener nombre Monitor PC  
  HOla seba123neo 
Mira estuve probando la Api EnumDisplayDevice , pero en la messagebox cuando deberia mostrar el tipo de monitor no me muestra nada no se que estare haciendo mal a ver si puedes dar una mano   
Pego el codigo del formulario   
Código:
  
Option Explicit On
Imports System.Runtime.InteropServices
Public Class Form1
    'for listview column auto-resizing
    Private Const LVM_FIRST As Long = &H1000
    Private Const LVM_SETCOLUMNWIDTH As Long = (LVM_FIRST + 30)
    Private Const LVSCW_AUTOSIZE As Long = -1
    Private Const LVSCW_AUTOSIZE_USEHEADER As Long = -2
    Const CCDEVICENAME As Short = 32
    Private Declare Function SendMessage Lib "user32" _
       Alias "SendMessageA" _
      (ByVal hwnd As Long, _
       ByVal wMsg As Long, _
       ByVal wParam As Long, _
    ByVal lParam As Long) As Long
    'EnumDisplayDevices Requirements
    '  Windows NT/2000/XP: Included in Windows 2000 and later.
    '  Windows 95/98/Me:   Included in Windows 98 and later.
    Private Structure DISPLAY_DEVICE
        Dim cb As Integer
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCDEVICENAME)> _
        Dim DeviceName As String
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
        Dim DeviceString As String
        Dim StateFlags As Short
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
        Dim DeviceID As String
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
        Dim DeviceKey As String
    End Structure
    Private Const DD_ATTACHED_TO_DESKTOP As Long = &H1
    Private Const DD_MULTI_DRIVER As Long = &H2
    Private Const DD_PRIMARY_DEVICE As Long = &H4
    Private Const DD_MIRRORING_DRIVER As Long = &H8
    Private Const DD_VGA_COMPATIBLE As Long = &H10
    Private Const DD_REMOVABLE As Long = &H20
    Private Const DD_DISCONNECT As Long = &H2000000 'WINVER >= 5
    Private Const DD_REMOTE As Long = &H4000000 'WINVER >= 5
    Private Const DD_MODESPRUNED As Long = &H8000000 'WINVER >= 5
   
    Private Sub Form_Load()
        With ListView1
            '.ListItems.Clear()
            '.View = lvwReport
            '.Sorted = False
            '.ColumnHeaders.Clear()
            '.ColumnHeaders.Add, , "DisplayDevice Member"
            ' .ListItems.Add, , "Device Name"
            ' .ListItems.Add, , "Device String"
            ' .ListItems.Add, , "Device StateFlags:"
            '.ListItems.Add, , "  - part of desktop"
            ' .ListItems.Add, , "  - primary device"
            '.ListItems.Add, , "  - pseudo device"
            '.ListItems.Add, , "  - VGA compatible"
            '.ListItems.Add, , "  - removable (cannot be primary)"
            '.ListItems.Add, , "  - more modes than output device"
            '.ListItems.Add, , "Assoc Monitor Name"
            '.ListItems.Add, , "Assoc Monitor String"
            '.ListItems.Add, , "Assoc Monitor StateFlags:"
            '.ListItems.Add, , "  - multi-driver"
        End With
        'Command1.Caption = "EnumDisplayDevices"
        Call EnumSystemDisplayDevices()
    End Sub
    Private Sub Command1_Click()
        Call EnumSystemDisplayDevices()
        Call lvAutosizeControl(ListView1)
    End Sub
    Private Sub EnumSystemDisplayDevices()
        Dim iDevNum As Long
        Dim thiscol As Long
        Dim sDeviceName As String 'required in 3 places
        Dim dev As DISPLAY_DEVICE
        'Query all display devices in the system by
        'calling EnumDisplayDevices in a loop, starting
        'with iDevNum set to 0, and incrementing until
        'the function fails (call returns non-zero if
        'true or 0 if false).
        dev.cb = Len(dev)
        iDevNum = 0
        Dim it As New Convert_Example.MyConvertExampleClass
        Do While EnumDisplayDevices(0&, iDevNum, dev, 0&)
            'for each display device returned,
            'add a new column to the listview
            'and populate its data
            With ListView1
                sDeviceName = TrimNull(it.convierte(dev.DeviceName))
                ' .ColumnHeaders.Add, , sDeviceName
                ' thiscol = (.ColumnHeaders.Count - 1)
                '.ListItems(1).SubItems(thiscol) = sDeviceName
                '.ListItems(2).SubItems(thiscol) = TrimNull(StrConv(dev.DeviceString, vbUnicode))
                '.ListItems(3).SubItems(thiscol) = dev.StateFlags
                If dev.StateFlags And DD_ATTACHED_TO_DESKTOP Then
                    '.ListItems(4).SubItems(thiscol) = "Yes"
                End If
                If dev.StateFlags And DD_PRIMARY_DEVICE Then
                    '.ListItems(5).SubItems(thiscol) = "Yes"
                End If
                If dev.StateFlags And DD_MIRRORING_DRIVER Then
                    '.ListItems(6).SubItems(thiscol) = "Yes"
                End If
                If dev.StateFlags And DD_VGA_COMPATIBLE Then
                    ' .ListItems(7).SubItems(thiscol) = "Yes"
                End If
                If dev.StateFlags And DD_REMOVABLE Then
                    '.ListItems(8).SubItems(thiscol) = "Yes"
                End If
                If dev.StateFlags And DD_MODESPRUNED Then
                    '.ListItems(9).SubItems(thiscol) = "Yes"
                End If
                'When null was passed as lpDevice above,
                'information about the display device (adapter)
                'was returned. By calling the API once again,
                'this time specifying lpDevice=dev.devicename and
                'iDevNum=0, the same call returns information about
                'the monitor connected to the specified device.
                If EnumDisplayDevices(sDeviceName, 0, dev, 0&) <> 0 Then
                    '.ListItems(10).SubItems(thiscol) = TrimNull(StrConv(dev.DeviceName, vbUnicode))
                    '.ListItems(11).SubItems(thiscol) = TrimNull(StrConv(dev.DeviceString, vbUnicode))
                    '.ListItems(12).SubItems(thiscol) = dev.StateFlags
                    MessageBox.Show("Moni es " & dev.DeviceString)
                    If dev.StateFlags And DD_MULTI_DRIVER Then
                        '.ListItems(13).SubItems(thiscol) = "Yes"
                    End If
                End If
            End With
            iDevNum = iDevNum + 1
        Loop
    End Sub
    Private Sub lvAutosizeControl(ByVal lv As ListView)
        Dim col2adjust As Long
        'Size each column based on the maximum of
        'either the ColumnHeader text width, or,
        'if the items below it are wider, the
        'widest list item in the column
        lv.Visible = False
        'For col2adjust = 0 To lv.ColumnHeaders.Count - 1
        'Call SendMessage(lv.hwnd, _
        '  LVM_SETCOLUMNWIDTH, _
        '  col2adjust, _
        '   ByVal LVSCW_AUTOSIZE_USEHEADER)
        'Next
        lv.Visible = True
    End Sub
    Private Function TrimNull(ByVal item As String)
        Dim pos As Integer
        'double check that there is a chr$(0) in the string
        'pos = InStr(item, Chr$(0))
        If pos Then
            'TrimNull = Left$(item, pos - 1)
        Else
            'TrimNull = item
        End If
    End Function
    <DllImport("user32.dll")> _
    Private Shared Function EnumDisplayDevices(ByVal Unused As Integer, ByVal iDevNum As Short, ByRef lpDisplayDevice As DISPLAY_DEVICE, ByVal dwFlags As Integer) As Integer
    End Function
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call EnumSystemDisplayDevices()
    End Sub
End Class
Respecto al WMi yo lo probe pero me sale Tipo de monitor estandar no me sale la marca       |