Struggling with wchar[] to string conversion

Stefan stefanliebig at web.de
Tue Jan 19 15:32:12 UTC 2021


Hi,

I am using dmd2.081.1 on windows building a 32 bit executable.

I am trying to find out how many instances of the same program 
are running. Therefor I use the core.sys.windows.tlhelp32 module.

With the CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) and 
Process32First/Process32Next I iterate over all processes and for 
each process I iterate with 
CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID) and 
Module32First/Module32Next over all modules of a process.
The Model32First/..Next fill a MODULEENTRY32 structure which 
contains a szExePath member that is a wchar[260].
Converting this to a string succeeds (compiler does not complain) 
with
me32.szExePath.text
However, comparing this with the result of thisExePath() 
(std.file) never succeeds although the two string values when 
written with writeln() appear to be the same.

This drives me crazy!

Any ideas?

Tschüß,
Stefan


More information about the Digitalmars-d-learn mailing list