Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have this bit of code from WMP11 SDK that returns an incorrect value.

Case CreateEditor.WMT_ATTR_DATATYPE.WMT_TYPE_GUID
tagValue = "{" & BitConverter.ToString(attribValue) & "}"

' tagValue = BitConverter.ToString(attribValue, 0, attribValue.Length)
' tagValue = Convert.ToBase64String(attribValue)
' tagValue = System.Text.UnicodeEncoding.ASCII(attribValue)
' tagValue = Encoding.ASCII.GetString(attribValue)
' tagValue = Encoding.Unicode.GetString(attribValue)
' tagValue = Encoding.UTF8.GetString(attribValue)

I have commented out other things I have tried. Most of them return gibberish.
attribValue.tostring returns {System.Byte[]}.

The above code (bitconverter.tostring) returns {BC-7D-60-D1-23-E3-E2-4B-86-A1-48-A4-2A-28-44-1E-00}.

I have another app that uses AxInterop.WMPLib and it returns {D1607DBC-E323-4BE2-86A1-48A42A28441E} as it should.

Any suggestions on what I might try?
Is there a way to determine what encoder was used?

Thank you
Posted
Comments
Sergey Alexandrovich Kryukov 30-Apr-12 11:54am    
Reason for my vote of 1
The question is totally incorrect. The answer depends on the content of the array of character, on what was serialized and, in case of text, in what encoding. I can see failure to understand it and pointless trial-and-error approach, a very dangerous trend in learning programming.
--SA
rctaubert 30-Apr-12 12:21pm    
"depends on the content of the array of character" I gave you that. {BC-7D-60-D1-23-E3-E2-4B-86-A1-48-A4-2A-28-44-1E-00} or if you prefer {188-125-96-209-35-227-226-75-134-161-72-164-42-40-68-30.0}

"on what was serialized" WMT_TYPE_GUID as evidenced by the return from WMPLib {D1607DBC-E323-4BE2-86A1-48A42A28441E}

"in what encoding" I would imagine that if I knew that I wouldn't be posting this question.

"pointless trial-and-error approach" I tried Goodling the problem and all of my 'trial-and-error' were recommendations to similar questions. At least I was trying to find an answer.

But I do want to thank you for taking time out of your busy schedule to leave your comment. It's just too bad you couldn't find something positive to offer.
rctaubert 30-Apr-12 13:11pm    
Again, thank you for replying.

From your statement "This is pointless, because no one except you knows what was actually encoded (serialized) as an array of byte." I believe it is you that doesn't understand

I didn't write this code. As I pointed out it comes from Microsoft's SDK for Windows Media Player 11. It is used to provide metadata from .wma files (songs). I DID NOT write the code and I DID NOT supply the data.

It works except for this one piece of code. I didn't realize it was returning an incorrect value until I saw what WMPLib returned. Some research lead me to conclude that WMPLib was correct.

Thank you for your suggestions concerning system.guid. However, none of them will take an argument of type system.byte[].
Sergey Alexandrovich Kryukov 30-Apr-12 14:28pm    
Sorry, I've written it in a wrong way. Please see the updated answer. It could be GUID byte-by-byte or per member. Please understand that I only trying to decipher the rebus -- I probably should not have done it. Still, a pointless question. You did not even published the byte values.
--SA
rctaubert 30-Apr-12 14:46pm    
You stated "You did not even published the byte values." Look back at my first replly to you.

"depends on the content of the array of character" I gave you that. {BC-7D-60-D1-23-E3-E2-4B-86-A1-48-A4-2A-28-44-1E-00} or if you prefer {188-125-96-209-35-227-226-75-134-161-72-164-42-40-68-30.0}

As to your reference to system.bitconverter if you will look at my original post, that is what MSs code uses and it doesn't return a correct value.

But thank you anyway.

1 solution

Do or Do not. There is no try.
Please see: http://www.youtube.com/watch?v=q3hn6fFTxeo[^].

Please see my comment to the question. This is pointless, because no one except you knows what was actually encoded (serialized) as an array of byte. This is not a programming question, as it should be pose in this forum, but a pure rebus. :-)

However, as you provided some indirect information and the expected result, let's try to guess what it could be. The encoded value was probably not a string. It could be GUID, but not in the string form. By the way, you should generally get a habit to work with data, not its string representation. So, assuming this is GUID, you could try to deserialize you array of chars as GUID, per component using BitConverter using the methods System.Guid.Parse, System.Guid.TryParse, System.Guid.ParseExact or System.Guid.TryParseExact, please see:
http://msdn.microsoft.com/en-us/library/system.guid.aspx[^],
http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx[^].

If this works, you should just work with this GUID value. You only need string to present it in a text file, show on screen, etc. As with any other data, you would need one of ToString methods.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900