Solved

ShellExecute returns 'Not enough actual parameters' if using SW_SHOWNORMAL

Posted on 2009-05-10
7
854 Views
Last Modified: 2012-05-06
Using Delphi BDS 2006, I get 'Not enough actual parameters' when compiling a ShellExecute statement, but ONLY if I use SW_SHOWNORMAL. If I pass SW_SHOW I do not get any error.
Also if I try this in a new application I don't get any problem. only in my existing application.

Here's the code:
var
  param: string;
begin
  param := 'calc';
  shellapi.ShellExecute(GetDeskTopWindow
    , 'open'
    , pChar(Param)
    , nil
    , nil
    , SW_SHOWNORMAL);
end;

Open in new window

0
Comment
Question by:rfwoolf
[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
7 Comments
 
LVL 13

Accepted Solution

by:
ThievingSix earned 213 total points
ID: 24350934
Thats weird, the only thing I can think of is try passing 1 instead of SW_SHOWNORMAL.
0
 
LVL 12

Assisted Solution

by:rionroc
rionroc earned 75 total points
ID: 24351414
uses ShellApi;
...
...

var
  param: string;
  h: Thandle;
begin
  h:=GetDeskTopWindow;
  param := 'calc';
  ShellExecute(h, 'open', pChar(Param), nil , nil , SW_SHOWNORMAL);
end;


Cheers!
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24351564
you could have declared a same named function with more parameters ...

what shows when press Ctrl-Space at the end of the function ?
1 of more functions ?
0
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!

 
LVL 13

Author Comment

by:rfwoolf
ID: 24351632
ThievingSix: Oddly enough, using 1 compiles.
rionroc: Using GetDesktopWindow unfortunatley doesn't help
Geert_Gruwez: Do you mean in the last parameter, or do you mean for example after the last bracket ) but before the semi-colon ; ? I assume you mean the last parameter. Then yes it brings up a list of constants starting with SW_SHOWNORMAL = 1.

I guess I can live with putting 1 in.

I will keep the question open though in case somebody has anything new to add.

By the way, if I try to think of anything I did to make it like this I know I changed the compile settings to 'include debug dcus' 'local symbols' etc etc. But when I took all of these off the problem persists - also in a fresh applicaiton if I enable all the debug things it doesn't give a problem.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24351785
Hitting ctrl-space just after the function ShellExecute, before the (
This should bring up the list of available functions starting with that name...
0
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 212 total points
ID: 24351798
or add the windows unit name in front of the parameter SW_SHOWNORMAL

var
  param: string;
begin
  param := 'calc';
  shellapi.ShellExecute(GetDeskTopWindow
    , 'open'
    , pChar(Param)
    , nil
    , nil
    , windows.SW_SHOWNORMAL);
end;
0
 
LVL 13

Expert Comment

by:ThievingSix
ID: 24351899
Yeh that was my guess Geert. There might be another declaration of SW_SHOWNORMAL somewhere in that project.
0

Featured Post

Technology Partners: 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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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