how can i exec a programme in dephi..

Posted on 2002-07-09
Last Modified: 2010-04-04
can someone plz tellme what the option is in winexec("bla.exe",ws_??);
or maybe a other funtion.. that hide the programme like not shown and can someone plz tellme how i can hide a programme from the thask and the progress list in windows xp..
maybe someone can plz give me some code for this or explain how.
if it's posible..

Carlos Smith
Question by:krydea
  • 4
  • 4

Expert Comment

ID: 7140299
The last parameter of WinExec() is to say how you want the new program displayed (Kind of like a window style parameter). It will except the following values:

SW_FORCEMINIMIZE - Windows 2000/XP: Minimizes a window, even if the thread that owns the window is hung. This flag should only be used when minimizing windows from a different thread.
SW_HIDE - Hides the window and activates another window.
SW_MAXIMIZE - Maximizes the specified window.
SW_MINIMIZE - Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE - Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW - Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT - Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
SW_SHOWMAXIMIZED - Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED - Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE - Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
SW_SHOWNA - Displays the window in its current size and position. This value is similar to SW_SHOW, except the window is not activated.
SW_SHOWNOACTIVATE - Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except the window is not actived.
SW_SHOWNORMAL - Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.

To hide your program from the task and process list in Windows XP then you would have to install your prog as a service. In Windows 9x its alot easier to do than on the NT platform.



Author Comment

ID: 7140317
can you explain me how i can reg it as a sevice?

Expert Comment

ID: 7140700
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.


Author Comment

ID: 7141132
i mean that you reg a app it self.. like you just all a the registerprogress in win 9x..
and the winexec doens't wait util the job is done? is there a funtion for with hide?

Expert Comment

ID: 7142956
Heres how to run an app and wait for its termination:

function WinExecAndWait32(FileName: string; Visibility: Integer): Longword;
  zAppName: array[0..512] of Char;
  zCurDir: array[0..255] of Char;
  WorkDir: string;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  StrPCopy(zAppName, FileName);
  GetDir(0, WorkDir);
  StrPCopy(zCurDir, WorkDir);
  FillChar(StartupInfo, SizeOf(StartupInfo), #0);
  StartupInfo.cb          := SizeOf(StartupInfo);
  StartupInfo.dwFlags     := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Visibility;
  if not CreateProcess(nil,
    zAppName, // pointer to command line string
    nil, // pointer to process security attributes
    nil, // pointer to thread security attributes
    False, // handle inheritance flag
    CREATE_NEW_CONSOLE or // creation flags
    nil, //pointer to new environment block
    nil, // pointer to current directory name
    StartupInfo, // pointer to STARTUPINFO
    ProcessInfo) // pointer to PROCESS_INF
    then Result := WAIT_FAILED
    WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
    GetExitCodeProcess(ProcessInfo.hProcess, Result);

procedure TForm1.Button1Click(Sender: TObject);
  WinExecAndWait32('notepad.exe', SW_HIDE);

As for to create a service all I can really tell you is to find out about the CreateService() and OpenService() functions. If you would like to just hide your app from the Applications list then you could do this:

procedure TForm1.FormShow(Sender: TObject);
  Owner : HWnd;
  Owner := GetWindow(Handle, GW_OWNER);
  ShowWindow(Owner, SW_HIDE);

Author Comment

ID: 7143066
i know and the start service i fond it ad delphipages..
but i realy need to find out how to start my programme as a service...

Expert Comment

ID: 7144859
To create a service application just goto: File->New->ServiceApplication in Delphi and then you just have to add your code to that.

Author Comment

ID: 7145409
i use delphi 5 so that doens't work with xp...

Accepted Solution

Mindphaser earned 0 total points
ID: 7258769
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 105
select query - oracle 16 100
tidtcpserver connection lost handle 2 84
Twebbrowser add css to the header 3 25
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In a recent question ( here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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