Get version of rich edit library
Asked Answered
E

1

6

ALL,

Is it possible to get the version of the RichEdit control the program uses?

| Version    | Class name    | Library      | Shipped with    | New features
|------------|---------------|--------------|-----------------|    
| 1.0        | "RICHEDIT"    | Riched32.dll | Windows 95      |
| 2.0        | "RichEdit20W" | Riched20.dll | Windows 98      | ITextDocument
| 3.0        | "RichEdit20W" | Riched20.dll | Windows 2000    | ITextDocument2
| 3.1        | "RichEdit20W" | Riched20.dll | Server 2003     |
| 4.1        | "RICHEDIT50"  | Msftedit.dll | Windows XP SP1  | tomApplyTmp
| 7.5        | "RICHEDIT50"  | Msftedit.dll | Windows 8       | ITextDocument2 (new), ITextDocument2Old, Spell checking, Ink support, Office Math
| 8.5        | "RICHEDIT50"  | Msftedit.dll | Windows 10      | LocaleName, more image formats

I know I can just have some variable and assign it appropriately if Msftedit.dll library is loaded or not. However if I do load RichEd20.dll, I can get either RichEdit 2 or RichEdit 3 implementation. And they are quite different. A lot of stuff were added in the latter.

If i did load Msftedit.dll, there are features that 7.5 that would not be available in earlier versions (e.g. automatic spell checking).

It's even possible that the same process can have all three DLLs loaded, and even using all three versions of RichEdit in the same process:

  • "RICHEDIT" → 1.0
  • "RichEdit20W" → 2.0, 3.0
  • "RICHEDIT50" → 4.1, 7.5, 8.5

Given a RichEdit control (e.g. WinForms RichTextBox, WPF RichTextBox, WinRT RichEditBox, VCL TRichEdit) is there a way to determine the version of a RichEdit control?

Or maybe I can somehow differentiate them by Windows version where it is available?

Ennius answered 4/9, 2015 at 12:10 Comment(4)
You can't use msftedit.dll by accident. Just read the product version number out of the version resource of riched20.dllWales
@HansPassant, Well, what do you mean "use by accident"? My code has an error checking and checks whether I load msftedit.dll or richedit.dll. But if I load richedit.dll, is it possible to know what is the version I'm using or I have to check the OS version, which is not reliable.Ennius
Hmm, no, you'll never load richedit.dll. Why don't you just use msftedit.dll consistently? No point in trying to support Windows 98/2000 anymore. You always get version 4.1Wales
@HansPassant, What about XP? I believe this guy have 3.0, i.e. exactly what my question is: choose between 2.0 and 3.0?Ennius
P
1

If using you may find the following snippet useful to read out the class name :

  TCHAR className[MAX_PATH];
  GetClassName(GetRichEditCtrl().GetSafeHwnd(), className, _countof(className));

GetRichEditCtrl() is function on another control, you may need to substitute with whatever gives you a hwnd to the control.

Another method is using a tool like spy++ to inspect the class name.

Puppet answered 20/11, 2019 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.