Solved

ShellExecute returns 'Not enough actual parameters' if using SW_SHOWNORMAL

Posted on 2009-05-10
7
845 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
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

16 Experts available now in Live!

Get 1:1 Help Now