10 Replies - 583 Views - Last Post: 30 August 2009 - 09:39 PM Rate Topic: -----

#1 atifshahzad708  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-May 09

problem in execution

Post icon  Posted 25 August 2009 - 08:20 PM

i am having a problem in opening two files simultaneously. when the code is executed it opens one exe file then i have to first exe file to run the second one. i want to run both exe fils simultaneously. the code is as below

// initializing program.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include "windows.h"

using namespace std;
void blend(void);

int _tmain(int argc, _TCHAR* argv[])
{
	
	
	system("C:\\Users\\fake\\Desktop\\value\\value.exe");
	blend();
	_getch();
	return 0;
}
void blend(void)
{
	system("D:\\project\\Evaluation\\imppp\\CreateDevicetestingleft\\Debug\\CreateDevice.exe");
}



anybody know how can i do it?

** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: problem in execution

#2 trixt.er  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 52
  • View blog
  • Posts: 428
  • Joined: 28-September 08

Re: problem in execution

Posted 25 August 2009 - 08:32 PM

View Postatifshahzad708, on 25 Aug, 2009 - 07:20 PM, said:

i want to run both exe fils simultaneously.

Do you realize that a lot of processors can only execute one thing at a time! Do you have a multi-core
processor. If so I would suggest using threads in Java to get the job done.
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5395
  • View blog
  • Posts: 27,389
  • Joined: 10-May 07

Re: problem in execution

Posted 25 August 2009 - 08:35 PM

Each time you call system, you are creating a new shell, & running the exe in that shell.
Was This Post Helpful? 0
  • +
  • -

#4 atifshahzad708  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-May 09

Re: problem in execution

Posted 25 August 2009 - 10:31 PM

i am using core 2 duo. but i do not know java. i only know c++. can i implemet it in c++?
Was This Post Helpful? 0
  • +
  • -

#5 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: problem in execution

Posted 25 August 2009 - 10:38 PM

if you're talking about multithreading... there are some good tutorials out there. though there's no 100% vanilla C++ way to do it... you'll have to use pthreads or something. Your best bet is to google for "multithreading tutorial C++" and see if that matches what you want. i would be more specific but i don't really understand exactly what you are trying to achieve and what you want the users experience of the application to be like
Was This Post Helpful? 1
  • +
  • -

#6 atifshahzad708  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-May 09

Re: problem in execution

Posted 25 August 2009 - 11:10 PM

i am trying to run an application in full screen mode and the other application to run over it. that's why i need a code which will execute an application and over it run another application.
Was This Post Helpful? 0
  • +
  • -

#7 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: problem in execution

Posted 26 August 2009 - 08:10 AM

are you on a windows or posix (linux, unix, etc) system?

EDIT: I'm an idiot. i should have looked at your example. windows... give me one sec.

This post has been edited by polymath: 26 August 2009 - 08:12 AM

Was This Post Helpful? 0
  • +
  • -

#8 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: problem in execution

Posted 26 August 2009 - 08:29 AM

ok here's my first go at it. reference: http://www.devarticl...reading-in-C/2/

// initializing program.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include "windows.h"

using namespace std;
DWORD WINAPI start_first(LPVOID param);
DWORD WINAPI start_second(LPVOID param);

unsigned short lock;

int _tmain(int argc, _TCHAR* argv[])
{
	lock = 2;
	LPDWORD id[2];
	HANDLE thread_handles[2];
	thread_handle[0] = CreateThread(NULL,0,start_first,NULL,NULL,id[0]);
	thread_handle[1] = CreateThread(NULL,0,start_second,NULL,NULL,id[1]);

	while(lock!=0);
	
	return 0; //when our function returns it destroys the thread...
}
DWORD WINAPI start_first(LPVOID param)
{
	system("C:\\Users\\fake\\Desktop\\value\\value.exe");
	lock--;
	return 0;
}
DWORD WINAPI start_second(LPVOID param)
{
	system("D:\\project\\Evaluation\\imppp\\CreateDevicetestingleft\\Debug\\CreateDevice.exe");
	lock--;
	return 0;
}


Was This Post Helpful? 1
  • +
  • -

#9 atifshahzad708  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-May 09

Re: problem in execution

Posted 26 August 2009 - 07:27 PM

i got an error when i executed this program.

Run-Time Check Failure #3 - The variable 'id' is being used without being initialized.
how can i solve this error. and thanks for ur reply.
Was This Post Helpful? 0
  • +
  • -

#10 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: problem in execution

Posted 27 August 2009 - 08:21 PM

just change LPDWORD id[2]; to LPDWORD id[2] = {0, 0};
Was This Post Helpful? 0
  • +
  • -

#11 atifshahzad708  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-May 09

Re: problem in execution

Posted 30 August 2009 - 09:39 PM

sorry for disturbance again. ur program worked. but i want my first application to run in full screen mood. and my second application to run over it while remaining in full screen mood.
can u give any hint about this?

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1