Solved

ShellExecute in VC++ 5

Posted on 1998-12-15
5
551 Views
Last Modified: 2006-11-17
I'm  trying to get ShellExecute to work but
I think I misunderstood how it works and
this came up:

: error C2660: 'ShellExecuteA' : function does not take 3 parameters
Error executing cl.exe.

Some working source code would be appreciated

Thanx
0
Comment
Question by:atsui
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
stsanz earned 100 total points
ID: 1180216
The compiler is right : ShellExecute function does not take 3 parameters but 6 parameters :

HINSTANCE ShellExecute (    
  HWND hwnd,    
  LPCTSTR lpOperation,
  LPCTSTR lpFile,    
  LPCTSTR lpParameters,    
  LPCTSTR lpDirectory,
  INT nShowCmd) ;      

Source code example follows.

0
 
LVL 6

Expert Comment

by:stsanz
ID: 1180217
To execute an application (e.g. NOTEPAD), use :
ShellExecute(NULL,"open","notepad.exe","",NULL,SW_SHOW) ;

To print a file (e.g. C:\TEMP\TEST.TXT), use :
ShellExecute(NULL,"print","C:\\TEMP\\TEST.TXT",NULL,NULL,SW_SHOW) ;

0
 
LVL 1

Author Comment

by:atsui
ID: 1180218
Hehe, turns out, I forgot about the escape character "\"
THanks for the source man
0
 

Expert Comment

by:sureshmovva
ID: 1180219
To execute an application (e.g. COMMAND), use :
     ShellExecute(NULL,"open","command.com","",NULL,SW_SHOW) ;

     To print a file (e.g. C:\TEMP\TEST.TXT), use :
     ShellExecute(NULL,"print","C:\\TEMP\\TEST.TXT",NULL,NULL,SW_SHOW);
0
 

Expert Comment

by:sureshmovva
ID: 1180220
ShellExecute function does not take 3 parameters but 6
   parameters :
        To execute an application (e.g. WINFILE), use :
        ShellExecute(NULL,"open","winfile","",NULL,SW_SHOW) ;

        To print a file (e.g. C:\TEMP\TEST.TXT), use :
        ShellExecute(NULL,"print","C:\\TEMP\\TEST.TXT",NULL,NULL,SW_SHOW);
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What does std::atomic give me? 7 123
C++ dll will not run on machine without VS installed 10 86
Compile GLUT with Visual Studio 2015 1 143
Problem with SqlConnection 4 168
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now