I want to know if it's possible writing a program, that just opens a Microsoft Word Document, and how. I really hope some of you guys will answer my question, cause I can't find any sites who explain it - only by using C# :(
Umm...double click on it?? I don't really know why you would want to open a word doc with a program...just use a shortcut or barring that, a batch file...
I think you misunderstood me... I want to know how to create a c++ program, that can open word. Fx:
#include <iostream>
using namespace std;
int main()
{
char a;
cout << "Press A to open word, or press E to quit";
cin >> a;
if(a=='a')
---open word---
else if(a=='e')
return 0;
else
return 0;
}
That's working! But not as perfect as I suspected. The command opens Microsoft Paint, but actually I have placed it in a while-loop:
#include <iostream>
#include <time.h>
#include <Windows.h>
using namespace std;
int main()
{
char hat;
int x=0;
cout << "Press A to start" << endl;
cin >> hat;
if(hat=='a')
{
x=1;
while(x==1){
system("mspaint");
}
return 0;
}
It should open A LOT of Microsoft Paint windows, but it only opens a single one. When I try to close down Paint, it opens again... and when I repeat that it opens again... so the loop is working in some way.
However, I want it to open again and again and again, so it opens about 10 or 200 times per second - I don't know how fast it will go...
If you want to use the system() and not the CreateProcess(), in order to open many windows (and not just one and wait to close it) then you can use system("start mspaint");system("mspaint"); runs mspaint but your program is halted until the mspaint is exited, when you close it it continues. system("start mspaint"); runs mspaint but your program keeps running, so it executes the same command again and again, so you have many mspaint windows.
I suggest not to use
1 2
while(true)
system("start mspaint");
except if you want to crash a system... and putting it in the startup applications will probably slow down the computer alot.
While trying it use a for-loop with 5-6 repeats...