Reading locale info from Clipboard

663 views Asked by At

using .NET Clipboard API you can write following code:

//dataObject - instance of IDataObject, received from Clipboard
if (dataObject != null)
{
    if (dataObject.GetDataPresent(DataFormats.Locale))
    {
        var data = dataObject.GetData(DataFormats.Locale);
        var locale = AsInt(data);
        if (locale.HasValue)
        {
            return new CultureInfo(locale.Value);
        }
     }
}

int? AsInt(object data); - my method which tries to read `Int32` value from `MemoryStream`

The question is why I always get en-US locale even when my PC's locale is ukrainian? I cannot get it, I thought Windows OS puts current locale info into clipboard when copy operation is performed? Isn't it?

UPD: I need to know locale of the object inside the clipboard, if it is possible

UPD2: My PC's locale is uk-UA, PC's UI locale is en-US, FAR Manager puts something different to clipboard (value 1024, which cannot be recognizsed as valid locale identifier). So it seems to be Excel2010 problem.

1

There are 1 answers

0
illegal-immigrant On BEST ANSWER