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 :confused:
How can I return and get string (char) value?
Any help will be appreciated
Printable View
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 :confused:
How can I return and get string (char) value?
Any help will be appreciated
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.
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.
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)
Sorry, Unregistered post was mine.
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.
If you are working within a subprocess, you could probably use SendMessage() to send the contents of your string back to it's parent.
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.
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.
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?