Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ShellExecute in VC++ 5

Posted on 1998-12-15
5
Medium Priority
?
579 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
stsanz earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

715 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