Discovering if you’re running on a RightToLeft Windows Operating System

I am currently working on ensuring that a chunk of VB6 code behave well on particular targeted versions of windows as part of an internationalised release of a software product. In order to complete the user experience I needed to detect whether or not we were running on one of the few windows versions that works RightToLeft instead of LeftToRight (I believe this is just Arabic and Hebrew windows although I may be wrong!). I’ve spent a good few hours over the past couple of days trying to track a way of doing this down. Searching MSDN and the www via google brought no luck. I tried a great variety of search terms including: “RightToLeft Windows detecting“, “RTL

After much searching and asking around at work I have finally tracked down a solution. So here it is for everyone else out there who is looking for a way to detect if the Windows version they are running on requires a RightToLeft layout.

VB6

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_MIDEASTENABLED = 74
Public Function RightToLeftLayoutRequired()
RightToLeftLayoutRequired = IIf(GetSystemMetrics(SM_MIDEASTENABLED) = 1, True, False)
End Function

.NET

public static bool RightToLeftLayoutRequired()
{
    return System.Windows.Forms.SystemInformation.MidEastEnabled;
}

Update: Fixed the .NET Code ๐Ÿ™‚

2 Responses to “Discovering if you’re running on a RightToLeft Windows Operating System”

  1. Daniel Moth says:

    Shouldn’t that be
    return System.Windows.Forms.SystemInformation.MidEastEnabled;

    (in fact why wrap a one liner anyway…)

    …you VB developers never learn ๐Ÿ˜‰

  2. westi says:

    @Dan: Ok I’ve fixed the code ๐Ÿ˜‰ and of course you wouldn’t wrap a one liner – unless you were protecting yourself against changes in the underlying Operating System – or wanted a way of testing RTL support without deploying to a RTL enabled machine.



d
go to dashboard
l
go to login
h
show/hide help
e
edit post/page
r
comment on post/page
m
go to moderate comments
esc
cancel
%d bloggers like this:
Skip to toolbar