Converting GUID -> string -> GUID
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Converting GUID -> string -> GUID

  1. #1
    Join Date
    May 1999
    Location
    UK
    Posts
    59

    Converting GUID -> string -> GUID

    An app I'm writing needs to associate archived data (using Access) with some unique identifier & I'm think about using GUID's. As far as I can see, I can create using ::CoCreateGUID()

    and convert it to a string using ::StringFromGUID2()

    However, there doesn't seem to be an API call going in the other direction for GUIDs (I've found CLSIDFromString & IIDFromString but no GUIDFromString). Anyone know how to go from String -> GUID?

    MJA

  2. #2
    Join Date
    Sep 2003
    Location
    M...N
    Posts
    220

    Re: Converting GUID -> string -> GUID

    GUID -> CString: ::StringFromGUID2()

    CString -> GUID: No way?


    Any exprienced guy(s)?

  3. #3
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Converting GUID -> string -> GUID

    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  4. #4
    Join Date
    Jul 2010
    Posts
    2

    Re: Converting GUID -> string -> GUID

    Sample with guid->string string ->guid and Guid::NewGuid() that we like in .net
    http://www.codequests.com/project.as...tId=Win32Guid#

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: Converting GUID -> string -> GUID

    Quote Originally Posted by coshe View Post
    Sample with guid->string string ->guid and Guid::NewGuid() that we like in .net
    http://www.codequests.com/project.as...tId=Win32Guid#
    Sorry, but I have to report your post as spam.
    Victor Nijegorodov

  6. #6
    Join Date
    Jul 2010
    Posts
    2

    Re: Converting GUID -> string -> GUID

    Sorry, I'm new. Didn't know that you can't link to non code-guru site.

    Here is the code to parse .net style Guid.ToString() output as win32 Guid.

    static bool TryParse( const WCHAR* wzGuid, _Out_ UUID& guid )
    {
    UUID rawGuid;
    wstring parenGuid( L"{" );
    parenGuid += wzGuid;
    parenGuid += L"}" ;
    HRESULT hr = CLSIDFromString( parenGuid.c_str(), &rawGuid );
    if( FAILED( hr ) )
    {
    return false;
    }
    guid = rawGuid;
    return true;
    }

    Please remove my previous post then. Thanks.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: Converting GUID -> string -> GUID

    Quote Originally Posted by brain123422 View Post
    ... You can use the below Online tools to convert string to GUID and and vice versa
    http://www.windowstricks.in/2011/05/...converter.html
    Didn't you read the post#5?
    Then
    Quote Originally Posted by VictorN View Post
    Sorry, but I have to report your post as spam.
    Victor Nijegorodov

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center