Solved

ShellExecute returns 'Not enough actual parameters' if using SW_SHOWNORMAL

Posted on 2009-05-10
7
850 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

776 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