VB Code:
' Decide if the measurement system of the current user is Metric (millimiter in PageSetupDialog or inches.
' There is a dotnet way to read the measurement system of the current culture-for example US culture is associated
' with US measurments (inch)-but that way wont reflect the user override of regional seetings in control panel.
' So read the registry value that shows the measurement system. If the value is not present at all, as in Win98SE
' or the value is 1 then its inches, and if 0 then its Metric.
Dim rgkey As RegistryKey, s As Integer
Try
rgkey = Registry.CurrentUser.OpenSubKey("Control Panel").OpenSubKey("International")
If rgkey.GetValue("iMeasure") = Nothing Then
s = 1
Else
s = CByte(rgkey.GetValue("iMeasure"))
End If
Catch ex As System.Exception
s = 1
Finally
rgkey.Close()
End Try
Then if the system is metric you have to multiply the document margins by 2.54 to convert it to mm.