Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ShellExecute returns 'Not enough actual parameters' if using SW_SHOWNORMAL

Posted on 2009-05-10
7
Medium Priority
?
864 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 852 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 300 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 38

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 38

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 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 848 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

926 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