Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShellExecute not working from IDE but works otherwise

Tags:

delphi

I want to create and then open a txt file using the ShellExecute command.

I have used this code for years with Delphi 7 and it worked:

function Execute(CONST ExeName, Parameters: string): Boolean;
begin
 Result:= ShellExecute(0, 'open', PChar(ExeName), PChar(Parameters), nil, SW_SHOWNORMAL)> 32;
end;

Now, I switched to Windows 7 and the code is not working anymore when it runs from IDE. Delphi shows the CPU window with the caption "CPU-Process unknown (2352)". I close the CU windows and everything works fine until I close the application, when Delphi shows the CPU window one more time. If I run the app from outside IDE, it works fine.

Looks like the debugger has something to say to me, but I don't know what.

like image 800
Server Overflow Avatar asked Oct 27 '25 01:10

Server Overflow


1 Answers

Sounds to me like you have the "debug spawned processes" option turned on. When that's enabled, the debugger interrupts the new process at the earliest possible time. Press the "run" button to let it continue running.

You can confirm this hypothesis the next time you debug your program. Compare the process ID (2352, in your example) with the list of processes shown by Task Manager. Which process in that list matches the process ID reported by the debugger?

like image 171
Rob Kennedy Avatar answered Oct 29 '25 20:10

Rob Kennedy