[C] Creating a simple windows front-end

This is a discussion on [C] Creating a simple windows front-end within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to learn the basics of WinAPI by writing a frontend for a console program in C. However, I'm ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    30

    [C] Creating a simple windows front-end

    I'm trying to learn the basics of WinAPI by writing a frontend for a console program in C.

    However, I'm not sure what is the function to call my command-line program. After some research, I found WinExec, CreateProcess and ShellExecute, but I'm not sure what I should use.

    My program consists basically of a combobox with some values and a Open File dialog. What I want it to do is run "myconsole.exe input_file combox_argument", and myconsole.exe is supposed to be in the same folder as the frontend.

    Using WinExec, I got my program to open in a console window, but if I choose a input_file outside of the myconsole.exe directory, winExec can't run it, I guess that's because he is trying to run from the last directory (the one where input_file was). A few questions:

    1 - How can I save the current directory (when you open the program) in a variable so I can have a string with the app_link (ie, C:\current_path\my_console.exe) ?
    2 - What function should I use?
    3 - Can I read return values from the console application (to know if the operation was sucessfull) ?

    Any source code examples from a front-end would also be nice.

    Thanks in advance

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    If you planning to add a console window into your app, you might want to search about CreateProcess with CREATE_NEW_CONSOLE flag.
    1 - How can I save the current directory (when you open the program) in a variable so I can have a string with the app_link (ie, C:\current_path\my_console.exe) ?
    2 - What function should I use?
    See GetCurrentDirectory or parse the return path in GetModuleFileName
    3 - Can I read return values from the console application (to know if the operation was sucessfull) ?
    Yes with pipes, you should use CreatePipe, PeekNamedPipe and ReadFile.
    Sorry, can't write you a sample EXE but that would give you a hint.
    http://img258.imageshack.us/img258/6518/google0dw.gif
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  2. Creating a Simple DLL in C
    By Ultima4701 in forum C Programming
    Replies: 2
    Last Post: 11-23-2002, 01:01 PM
  3. Creating a simple database: is my approach OK?
    By m712 in forum C++ Programming
    Replies: 1
    Last Post: 11-18-2002, 02:27 AM
  4. Creating Windows from Console
    By ashu12 in forum Windows Programming
    Replies: 3
    Last Post: 10-21-2002, 06:21 AM
  5. creating a simple program to accept a password.
    By boy1015 in forum C++ Programming
    Replies: 11
    Last Post: 02-05-2002, 08:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21