473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to launch a EXE file from within the VC++ code?

Hello!

Could someone please help me figure out how to run an executable file from within the soure code and pass the commands to the exe file to be launched!

I was trying to use tools.shell, but it gives me error...

please help....
Oct 5 '06 #1
5 16570
Banfa
9,065 Expert Mod 8TB
Call CreateProcess
Oct 6 '06 #2
Thanx a lot Banfa for your reply!

I tried using CreateProcess. But I keep getting the error "Unhandled exception at 0x7c825352 in InventoryFiles.exe: 0xC0000005: Access violation writing location 0x006a3ce2.".

I dont know where the problem lies.

the part of code I used for my testing of this function is -
-----------------------------------------
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

CreateProcess( NULL, // No module name (use command line)
TEXT("NOTEPAD"), // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) ; // Pointer to PROCESS_INFORMATION structure

-------------------------------------------------------------------

Kindly point out my error...

Thank you....
Oct 6 '06 #3
You can use ShellExecute Function to execute any exe from VC++ code.

Hope that will help you.

Jagdish
Oct 7 '06 #4
Hello Jagdish!

Thank you for your reply!

Can you please tell me how to open the command prompt using shellexecute...

thank you once again....
Oct 9 '06 #5
Hello !

to conitnue my previous post, below is the part of the code where I am trying to launch notepad through command prompt using shellexecute.

with this, the commandprompt does come up, but the text "NOTEPAD" is not passed to the command window. please help me do that...

.................................................. ...................
int x = (int)ShellExecute(NULL, NULL, L"C:\\WINDOWS\\system32\\cmd.exe", L"NOTEPAD", NULL, SW_SHOWNORMAL);

................................................

thanx a ton....
Oct 9 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: T | last post by:
I am attempting to create a menu using <div> and <span> tags within a table cell. When the page loads, some of the classes don't seem to be applied. If I hover over the menu everything is fine...
6
by: Omid | last post by:
Hi. I have problems when I try to redirect everything that is sent to cout to a file. I have one piece of code that works and one that does not work. The only difference is which headers I use....
5
by: GrantS | last post by:
Hi I am trying to use ShellExecute to launch an application to display a certain file. The variation on the theme is that I need to be able to specify the application to launch and not simply...
2
by: DavideR | last post by:
How to launch a exe in a vc++ 2002 program? What is the equivalent of vb6's app.path? How can i get the exe name? Thanks davide
4
by: Joe | last post by:
I created a CustomAction for this but I don't think I have it in the right place. I tried both Install and Commit but neither allow it to get to the final screen. Are there any examples of this...
1
by: sylsau | last post by:
Hello, I wrote a JAVA program which uses the JAVA API JDOM 1.0 (of this site www.jdom.org) I put the archive jdom.jar in the directory /usr/share/java/jdom.jar and I added this path in the...
7
by: Bob | last post by:
I have a media file Myfile.wme that I want to play within the Windows default media player on a button or menu click event in my app. The file is in a folder relative to my bin folder. I can...
6
by: Ronald S. Cook | last post by:
How do I launch, say, Microsoft Word from within a C# Win app? Word should launch exterior to my app, of course. Is it easy to set size and position of where Word window will be placed? ...
5
by: cooltoriz | last post by:
Hello there, I am not asking how to impersonate a process within C# windows application. I already know that, in C# v2.0, you can easily achieve it using ProcessStartInfo. You can run a process...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.