CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2008
    Posts
    57

    Using an API Function -> SetupDiGetClassDevs ?

    Hi.
    I'm using SetupDiGetClassDevs function in my App.
    This is my snippet code , but it's wrong
    and this Exception is occurring .

    Code:
    [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SetupDiGetClassDevs( 
       ref Guid ClassGuid,
       IntPtr Enumerator,
       IntPtr hwndParent,
       int Flags
    );
    
    static Guid DiskGUID = new Guid("GUID_DEVINTERFACE_DISK");
    
    static void Main(string[] args)
    {
        IntPtr h = SetupDiGetClassDevs(ref DiskGUID, IntPtr.Zero, IntPtr.Zero, 1);
    
        //Console.WriteLine(h);
        Console.ReadKey();
    }
    Would you guide me how I can use it ?
    Thanks

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Using an API Function -> SetupDiGetClassDevs ?

    The problem is with

    Code:
    static Guid DiskGUID = new Guid("GUID_DEVINTERFACE_DISK");
    Find out the actual GUID and put that into the string.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured