Get version of rich edit library - dll

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?

If using c++ 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.

Related

How to add extra info to BenchmarkDotNet summary?

How can I add extra informationto extend the summary information produced by BenchmarkDotNet?
Like:
current host name or
current (Git) branch name
I would like to achieve something similar to this example:
Host MachineName: <Environment.MachineName>
Branch: <Git-Branch-Name>
BenchmarkDotNet=v0.13.1, OS=Windows 10...
Intel Core i7...
[Host] : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT
Dry : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT
Job=Dry IterationCount=1 LaunchCount=1
RunStrategy=ColdStart UnrollFactor=1 WarmupCount=1
| Method | Mean | Error |
|----------------- |----------- |------ |
| Foo | 1,940.3 ms | NA |
Currently there is no way to extend the Summary with extra data. All you can do is to implement a custom column and add it to the config: https://benchmarkdotnet.org/articles/configs/columns.html

Intellij idea 2021.2 cannot render markdown table currently?

I use idea 2021.2 and corresponding markdown plugin. But the simple table cannot display in previous mode:
Why? I found somebody has related the problem to the JavaFx, however, I think it is occured in old version idea. I cannot find javafx render option in my version.
How to solve it?
You are using the wrong Markdown syntax.
The following code works fine (minimum three - for table header)
| Column 1 | Column 2 |
| :--- | :--- |
| AAA | BBB |

How to find out where the main function in an .exe file is?

I created a simple .exe file that just assigns a value of 3 to an integer called "x" and then prints out that value.Here is a picture of the source code:
source code
I opened the .exe file with an hex editor(named HxD) and used the disassembly function of Visual Studio 2017 to show me the opcodes of my main function. After a bit of search i found out that the main function is stored in the file at Offset 0xC10
Here is the disassembly:disassembly
And here is the file in the Hex-Editor:hexadecimal view of .exe file
I know that some values of the .exe file in the hex editor vary from what the visual studio debugger says but i know that the main starts there because i changed the value of x in the hex editor and then when i started the .exe it printed out another value instead of the 3. My question is where in the .exe file is the value that says:"At that point of the file start the opcodes of the main function."
For example in a .bmp file the 4 bytes at positions 0x0A,0x0B,0x0C and 0x0D tell you the offset of the first byte of the first pixel.
On Windows, the entry point of an executable (.exe) is set in the PE Header of the file.
WikiPedia illustrates the structure of this header like this (SVG file).
Relative to the beginning of the file, the PE Header starts at the position indicated at the address
DWORD 0x3C Pointer to PE Header
File Header / DOS Header
+--------------------+--------------------+
0000 | 0x5A4D | | |
0008 | | |
0010 | | |
0018 | | |
0020 | | |
0028 | | |
0030 | | |
0038 | | PE Header addr |
0040 | | |
.... | .................. | .................. |
And the entry point is designated at the position (relative to the address above)
DWORD 0x28 EntryPoint
PE Header
+--------------------+--------------------+
0000 | Signature | Machine | NumOfSect|
0008 | TimeDateStamp | PtrToSymTable |
0010 | NumOfSymTable |SizOfOHdr| Chars |
0018 | Magic | MJV| MNV | SizeOfCode |
0020 | SizeOfInitData | SizeOfUnInitData |
0028 | EntryPoint (RVA) | BaseOfCode (RVA) |
0030 | BaseOfData (RVA) | ImageBase |
0038 | SectionAlignment | FileAlignment |
0040 | ... | ... |
from the beginning of the PE Header. This address is a RVA (Relative Virtual Address) what means that it is relative to the Image Base address that the file is loaded to by the loader:
Relative virtual addresses (RVAs) are not to be confused with standard virtual addresses. A relative virtual address is the virtual address of an object from the file once it is loaded into memory, minus the base address of the file image.
This address is the address of the main function.
A .exe is a portable executable.
Layout
Structure of a Portable Executable 32 bit
A PE file consists of a number of headers and sections that tell the dynamic linker how to map the file into memory. An executable image consists of several different regions, each of which require different memory protection; so the start of each section must be aligned to a page boundary.[4] For instance, typically the .text section (which holds program code) is mapped as execute/readonly, and ...
So really it is a question of where the .text section is in the file. Exactly where depends on the headers and locations of the other sections.

postgres 9.5 create function plpthon3u resets connections to server

I have installed postgresql 9.5 on windows 10, x64.
I have created the extension plpython3u with python 3.3.5 on the server's path and it appeared to create the extension successfully:
SELECT * FROM pg_available_extensions
WHERE name like '%python%' order by name;
name | default_version | installed_version | comment
-------------------+-----------------+-------------------+------------------------------------------
-
hstore_plpython2u | 1.0 | | transform between hstore and plpython2u
hstore_plpython3u | 1.0 | | transform between hstore and plpython3u
hstore_plpythonu | 1.0 | | transform between hstore and plpythonu
ltree_plpython2u | 1.0 | | transform between ltree and plpython2u
ltree_plpython3u | 1.0 | | transform between ltree and plpython3u
ltree_plpythonu | 1.0 | | transform between ltree and plpythonu
plpython2u | 1.0 | | PL/Python2U untrusted procedural language
plpython3u | 1.0 | 1.0 | PL/Python3U untrusted procedural language
plpythonu | 1.0 | | PL/PythonU untrusted procedural language
(9 rows)
However when I attempt to create the following function (from the pg docs)
CREATE FUNCTION pymax (a integer, b integer)
RETURNS integer
AS $$
if a > b:
return a
return b
$$ LANGUAGE plpython3u;
the psql (or pgadmin3) terminal's connection is reset.
The python 3.3 on the path is anaconda's distb and runs fine on its own. I couldn't find the required version of python in the postgresql docs and used dependency walker as described here Postgres database crash when installing plpython to find the required dll that plpython3.dll in the server's lib/ points to.
Can anyone help me with what I have missed?
Many thanks
Looking more carefully at the installation download, I read the readme.txt. This clearly lays out how to include the language packs including plpython. No need to muck around with dependency walker or anything like that.
Following the clear and simple instructions in the readme.txt is all it took to get the plpython extension working fine. No excuse for not reading the readme. My bad.
I was not matching the required version of python. The bottom line is that postgresql does seem to be relatively sensitive to the particular distribution of python, not just version - (I had matched the versions postgres python distb 3.3.4 and anaconda 3.3.4.)
Specifically, setting the server's path to use the python installed along with the server, C:\EnterpriseDB\LanguagePack\9.5\x64\Python-3.3 in my case, was all that it took to get it working correctly.
Thanks go to Adrian Klaver on the pgsql-general mailing list for getting me sorted. This answer is just for future reference as I claim it is easy to miss the readme :-).

Font metrics for the "base 14" fonts in the PDF specification

I've been writing software to parse content from PDFs, specifically text broken into regions. For this I need font metrics such as glyph displacements, font-wide ascent, descent and glyph bounding box, etc. In short, the type of metrics that should be available in the FontDescriptor dictionary of a font definition in a PDF.
Unfortunately a FontDescriptor doesn't have to be included for fonts whose base font is one of the "base 14" set of standard fonts.
Where can I find or how can I generate font metrics for the base 14 fonts?
Meanwhile I've found these links on an Adobe Website, which contain the information asked for:
Font Metrics for Base 14 fonts (Windows)
Font Metrics for Base 14 fonts (UNIX)
Font Metrics for Base 14 fonts (Macintosh)
On Linux (and probably on Mac OS X too) you can easily use the font2afm script which creates font metrics files from PostScript or TrueType fonts (.pfa, .pfb, .ttf, .otf).
If you don't have the original Base 14 available, you can use the clones provided by Ghostscript. These clones may use completely different font names, but they can only be clones by using the very same metrics for each glyph.
Here is a Ghostscript commandline, that lists you all the base 14 fontnames:
Windows:
gswin32c.exe -q -dNODISPLAY -dSAFER -c "systemdict /.standardfonts get == quit"
Linux/Unix/Mac:
gs -q -dNODISPLAY -dSAFER -c "systemdict /.standardfonts get == quit"
In recent versions of Ghostscript, the filenames for cloned fonts usually match the clone's fontname. Older GS versions may have used more cryptic nameing conventions. Here is the list of fontname mappings to the cloned fonts:
+===============+========================+==========================+
| Base 14 name | Ghostscript name | Font filename (older GS) |
+===============+========================+==========================+
| Courier | | |
| standard | NimbusMonL-Regu | n022003l.pfb |
| bold | NimbusMonL-Bold | n022004l.pfb |
| italic | NimbusMonL-ReguObli | n022023l.pfb |
| bolditalic | NimbusMonL-BoldObli | n022024l.pfb |
+---------------+------------------------+--------------------------+
| Helvetica | | |
| standard | NimbusSanL-Regu | n019003l.pfb |
| bold | NimbusSanL-Bold | n019004l.pfb |
| italic | NimbusSanL-ReguItal | n019023l.pfb |
| bolditalic | NimbusSanL-BoldItal | n019024l.pfb |
+---------------+------------------------+--------------------------+
| Times-Roman | | |
| standard | NimbusRomNo9L-Regu | n021003l.pfb |
| bold | NimbusRomNo9L-Medi | n021004l.pfb |
| italic | NimbusRomNo9L-ReguItal | n021023l.pfb |
| bolditalic | NimbusRomNo9L-MediItal | n021024l.pfb |
+---------------+------------------------+--------------------------+
| Symbol | StandardSymL | s050000l.pfb |
+---------------+------------------------+--------------------------+
| ZapfDingbats | Dingbats | d050000l.pfb |
+---------------+------------------------+--------------------------+
You can download the Ghostscript fonts from many places on the 'net (f.e. from here). Then run f.e. this command:
font2afm StandardSymL.ttf
and the resulting file, StandardSymL.afm should contain the font metrics for the Symbol font in standard .afm format....
I'm sure those font metrics are widely available. For instance, in my Ubuntu they're in /usr/share/fonts/type1/gsfonts/ -- maybe you don't recognize some of the font names, but they're metrically compatible to Helvetica etc.