String to GUID in C++ only

Discussion in 'Windows Vista Drivers' started by LEMAIRE Mathieu, Dec 20, 2006.

  1. This seems to exist in .Net but I would like to do it in C++ only (no
    MFC, .net, ATL...)

    Do you have any snippet of code doing this ?

    GUID StringToGUID(const String myGuidAsAString)
    {
    //???
    }

    Any help would be much appreciated,

    Mathieu LEMAIRE
     
    LEMAIRE Mathieu, Dec 20, 2006
    #1
    1. Advertisements

  2. LEMAIRE Mathieu

    Don Burn Guest

    Well since you are asking in a device drivers group, .NET makes no sense,
    but for a kernel driver, use:

    NTSTATUS status;
    UNICODE_STRING s;
    GUID g;

    RtlInitUnicodeString(&s, myGuidAsAString);
    status = RtlGuidFromString(&s, &g);
     
    Don Burn, Dec 20, 2006
    #2
    1. Advertisements

  3. Thanks, but do you have the same functions without using the DDK ?

    In fact, what I want to do is maybe out of this group matters... but I
    could not find any more appropriate :

    I want to call /SetupDiGetClassDevs(guid, ...)/ using a guid object
    created from a String taken from the command line :

    int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
    {
    GUID guid = ????StringToGUID(argv[1]);
    ... = SetupDiGetClassDevs(guid, ...);
    ...
    }

    Mathieu LEMAIRE
     
    LEMAIRE Mathieu, Dec 20, 2006
    #3
  4. LEMAIRE Mathieu

    Ray Trent Guest

    It's surprisingly hard to figure that out... Probably because you're
    supposed to *know* the GUID you're working with...people rarely want to
    enumerate them.

    Anyway, I think UuidFromString will do what you want. UUID is a typedef
    for GUID in RPC land...

     
    Ray Trent, Dec 20, 2006
    #4
  5. LEMAIRE Mathieu

    Tim Roberts Guest

    It's foolish to discard ATL out of hand. ATL contains a large number of
    very useful and lightweight tools that can make your C++ code simpler and
    more reliable.
    CLSIDFromString will do exactly what you want.
     
    Tim Roberts, Dec 22, 2006
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.