Solved

how can i exec a programme in dephi..

Posted on 2002-07-09
11
256 Views
Last Modified: 2010-04-04
hello,
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
0
Comment
Question by:krydea
[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
  • 4
  • 4
11 Comments
 
LVL 5

Expert Comment

by:alanwhincup
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.

Cheers,

Alan
0
 

Author Comment

by:krydea
ID: 7140317
can you explain me how i can reg it as a sevice?
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 7140700
0
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!

 

Author Comment

by:krydea
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?
0
 
LVL 5

Expert Comment

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


function WinExecAndWait32(FileName: string; Visibility: Integer): Longword;
var
  zAppName: array[0..512] of Char;
  zCurDir: array[0..255] of Char;
  WorkDir: string;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  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
    NORMAL_PRIORITY_CLASS,
    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
  else
  begin
    WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
    GetExitCodeProcess(ProcessInfo.hProcess, Result);
    CloseHandle(ProcessInfo.hProcess);
    CloseHandle(ProcessInfo.hThread);
  end;
end;

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

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);
var
  Owner : HWnd;
begin
  Owner := GetWindow(Handle, GW_OWNER);
  ShowWindow(Owner, SW_HIDE);
end;
0
 

Author Comment

by:krydea
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...
0
 
LVL 5

Expert Comment

by:alanwhincup
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.
0
 

Author Comment

by:krydea
ID: 7145409
i use delphi 5 so that doens't work with xp...
0
 
LVL 6

Accepted Solution

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

** Mindphaser - Community Support Moderator **
0

Featured Post

Independent Software Vendors: 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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

628 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