Hi All,
I try to write simply WinGUI dialog that collects user input and returns it to calling program. But I see that WinMain could return only int
How can I return and get string (char) value?
Any help will be appreciated
Hi All,
I try to write simply WinGUI dialog that collects user input and returns it to calling program. But I see that WinMain could return only int
How can I return and get string (char) value?
Any help will be appreciated
Vaidotas.Vilnius.lt
When WinMain returns, it returns it's value to the operating system and terminates the program. The international C++ standard requires that your "main" returns an integer. If you want to return something other than that, I would suggest you have a design problem, or have not explained your question!
Welcome, by the way, we do not get many visitors from the Baltic republics.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Just so you know, that 32-bit int returned from WinMain() is four bytes, and a pointer to a char array is also four bytes.
"Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C
johnnie2,
thanks for your idea.
But how to retain char array in memory to be available for calling program? I suppose to use ShellExecute or something like for calling...
(Adrian, I know that my straightforward approach is bad, I just ask about ways usually applied)
As said
>>If you want to return something other than that, I would suggest you have a design problem, or have not explained your question!
a DLL would be better if you need a seperate interface. Send it the string to fill in.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
If you are working within a subprocess, you could probably use SendMessage() to send the contents of your string back to it's parent.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
The simplest (and crudest) way of returning data from a program is to get the program to write the data into a temporary file before it terminates. The calling process can then read the file.
>>> The simplest (and crudest)
True of course, but then the writing program would need to tell the reading program that the data had been written. Messy - part written files, old files from previous runs, etc....
Yup, can be done, but is not a real option in a rtue multitasking OS environment.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Elaborating on an earlier response, you could use FindWindow() to locate your parent window and send a WM_COPYDATA message, which apparently exists especially for this situation.
Another possibility is the clipboard.
"Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C
Yes, thanks a lot, now I see - WM_COPYDATA message is right method when I have C++ or VB apps on both sides.
Besides I wonder whether it's possible to write application which sends a message/string into VBScript? Maybe I should create COM Automation object for this purpose or can someone mention another way?
Vaidotas.Vilnius.lt