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

x
?
Solved

Application freezes after ShellExecuteEx

Posted on 2013-06-16
2
Medium Priority
?
781 Views
Last Modified: 2013-06-16
Hi all.

After the execution of this function (which I use to merge a .reg file into the Windows registry), application freezes: the file is merged I see the usual prompts which ask for merging file and confirming the merging has been successful, then The Explorer window when I started my app brings to front and my application can't get focus.

Any idea?

function TfrmMain.RunAsAdmin(hWnd: HWND; aFile,
  aParameters: String): Boolean;
var
  sei: TShellExecuteInfo;
  ExitCode: DWord;
begin
  Result := False;
  FillChar(sei, SizeOf(sei), 0);
  sei.cbSize := SizeOf(sei);
  sei.Wnd := hWnd;
  sei.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_UNICODE;
  sei.lpFile := PChar(aFile);
  sei.lpParameters := PChar(aParameters);
  sei.nShow := SW_SHOWNORMAL;
  if ShellExecuteEx(@sei) then
  begin
     repeat
       Application.ProcessMessages;
       GetExitCodeProcess(sei.hProcess, ExitCode) ;
     until (ExitCode <> STILL_ACTIVE) or
                        Application.Terminated;
     result := True;
  end;
end;

Open in new window


Thanks to all in advance.
Marco
0
Comment
Question by:Marco Gasi
2 Comments
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 2000 total points
ID: 39251632
try delphidabblers code ExecAndWait under windows shell

http://snippets.delphidabbler.com/
0
 
LVL 31

Author Closing Comment

by:Marco Gasi
ID: 39252230
Thanks, Geert. It seems the problem is in another part of my code and when I'll find where I'll post a new question. But I award points fr the interesting resource I didn't knew :)

Cheers
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

963 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