how to open a program with c++

Aug 30, 2013 at 1:35pm
So I have designed my own mini game as a present for my brother, and at the end you beat a dragon. I am trying to get it to run SlayTheDragon.vbs (that creates a pop up that says Congratulations! You have slain the dragon!) and nothing I have tried works. Can I have some help?
P.S. The order is like this:
Open Game
Play Game
Beat Game
Pop Up (SlaytheDragon.vbs)
Aug 30, 2013 at 1:51pm
I am trying to get it to run SlayTheDragon.vbs
nothing I have tried works

What have you tried?

Andy
Aug 30, 2013 at 2:27pm
The only thing I have tried is using the system() command. The code for SlayTheDragon.vbs is:
dragon=msgbox("Congratulations! The dragon has been slain!",14,"Congratulations!")
Aug 30, 2013 at 2:44pm
system("SlaytheDragon.vbs");

works for me, with a bit of a lag while things run up. If it doesn't for you it means either (a) your program can't find the file or (b) the association is not set up for some reason (does "SlaytheDragon.vbs" work at the command line?)

But if you just want to display a dialog, you can use the WinAPI MessageBox call from your program (a console program??)

Andy

1
2
3
4
5
6
7
8
9
10
11
12
13
#define WIN32_LEAN_AND_MEAN // only include code APIs
#include <windows.h>        // for MessageBoxA, etc
#include <iostream>

int main()
{
    std::cout << "Hello world!" << std::endl;

    HWND hwnd = GetConsoleWindow();
    MessageBoxA(hwnd, "Hello world, again!", "test.exe",
                MB_OK | MB_ICONEXCLAMATION);
    return 0;
}
Last edited on Aug 30, 2013 at 2:45pm
Topic archived. No new replies allowed.