Hi,

I've developed a console app and a win32 api GUI. The GUI is only used to get input file path and output file path specified by the user, as simple as that. I now want to pass those file path and call the functions in my console app to process the data but not quite sure what is the best way. I'm quite new to programming:D

Here are my thoughts:
1. convert console app to windows app and make the two projects into one, then make function calls in winmain?
or
2. create a dll project and somehow link the two projects?
or
3. probably the easiest way is to let the GUI store the input and output file path in a text file and then use createprocess() to call the console app which reads input output file path from the file?

I've done a lot of research on this but kinda got lost. I'd be really grateful if anyone would point me in the right direction. I believe there must be a common way of doing this kind of thing which I just don't know. The code is really long over a thousand lines but if anyone want to have a look I will put here.

Thank you in advance for your help.

Why would you want to keep the console application seperate? There aren't (m)any real world applications that spawn a new process to do some work and only use the GUI for configuration.

So just create one GUI project, and put the code from the console application in there... You will probably have to make some modifications but I would go that way.

If you decide to use CreateProcess anyway you don't need to store the configuration in a file, you can pass it as a command line parameter.
Just like you can create a process through cmd like:
>myProgram.exe argument1 argument2

Why would you want to keep the console application seperate? There aren't (m)any real world applications that spawn a new process to do some work and only use the GUI for configuration.

So just create one GUI project, and put the code from the console application in there... You will probably have to make some modifications but I would go that way.

If you decide to use CreateProcess anyway you don't need to store the configuration in a file, you can pass it as a command line parameter.
Just like you can create a process through cmd like:
>myProgram.exe argument1 argument2

I'm just really really new to programming...so pls bear with me if I have said something silly. I don't want to keep them seperate, that's just one of my naive thoughts. I have considered to make the two projects into one if you see that:D

So I could just convert the console app to a windows app and put all the functions in the GUI project then? I don't know how this could be achieved and what modifications I would have to make. Thank you very much.

Your console application has some functions, that are probably called from the main() function.

This 'logic' you need to put in the GUI application, but instead of calling the functions from winmain you can call them for example when the user clicks a button on your GUI, and you pass as a parameter any configuration that the user did in your GUI.

I can't tell you what changes you have to make, because I dont know how you coded your Console app... but some obvious things like 'cout' won't work in the GUI app.

Your console application has some functions, that are probably called from the main() function.

This 'logic' you need to put in the GUI application, but instead of calling the functions from winmain you can call them for example when the user clicks a button on your GUI, and you pass as a parameter any configuration that the user did in your GUI.

I can't tell you what changes you have to make, because I dont know how you coded your Console app... but some obvious things like 'cout' won't work in the GUI app.

Thank you so much for your help so far.:)

I actually tried making my console app into a windows app and searched on the web but could not find help. Yes, as my program is only to process some data on one click, so I was going to make the main as a function but no success.:(

I'm coding my console app in visual c++. I have tried and know that things like cout won't work. I have mainly used string, fstream, vector and iostream. So iostream does not work in a windows app. I know that you can't possibly tell me every detail, but could you give me some general guidance pls?

When I compile my program I got some error ***winmain16*** I can't remember clearly. I have classes in my program and basically all I have done is some string manipulation. What are the major changes that I would have to make? Thanks!!

Your console application has some functions, that are probably called from the main() function.

This 'logic' you need to put in the GUI application, but instead of calling the functions from winmain you can call them for example when the user clicks a button on your GUI, and you pass as a parameter any configuration that the user did in your GUI.

I can't tell you what changes you have to make, because I dont know how you coded your Console app... but some obvious things like 'cout' won't work in the GUI app.

Thanks a lot. Seems like only some small changes to make and I've figured it out:D
Thank you for pointing me in the right direction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.