Hi
I am trying to open new console window and be able to write to it. My attempts failed. How to do that? (currently using MinGW)
During my attempts I tried to create process using startProcess I noticed that I can get then FileHandle for process. However I do not know how obtain File to which I could write (like stdout), I also have seen FileInfo. So having File, FileHandle, FileInfo - could someone give some hints about them? I could also fetch input Stream.
Also tried
proc shellExecuteW(HWND: Handle;
lpOperation, lpFile, lpParameters, lpDirectory: WideCString;
nShowCmd: int32): Handle {..}
Here I do not know how to change string to WideCString.
Third. Is it difficult (it is not, but for me it is) to switch to vcc compiler? Are there any easy manual for that?
Thanks in advance for any help. So many questions in one but this is because long time I was unable to register to forum and it was raising.
Regards Michal /The really bad programmer/
Here's an incomplete idea that may or may not be helpful...
There might be some fancy Windows API tricks for interacting with other console windows, but then your code would be more difficult to port. I would first consider the simplest solution: startProcess the start and cmd with the needed switches, command, and the rest of the args. That will spawn a new console window, but I don't think you can access its I/O streams the same way.
It is common for an exe to fork a copy of itself with special args, and even communicate via a portable IPC library (nanomsg?) if needed. Then the only Windows-dependent thing is how the visible console window is launched, for which there are one-line equivalents on other GUI platforms (ex. xterm / gnome-terminal, open -a Terminal on Mac, etc).
If I understand what you need, to convert a "string" to "WideCString", you can do the following:
# Convert a "string" to "WideCString".
proc toWideCString(str: string): WideCString =
var
i : int = 0
ret : WideCString
new(ret)
while i < str.len():
ret[i] = Utf16Char(str[i])
i = i + 1
return ret
# Example:
var str : WideCString
str = toWideCString("Nim language")
echo str
Why is this so? Moderation?
Yes.