Windows Explorer Context menu opening already running Delphi app - delphi

If I right click on several files and choose windows context menu, how to send the selected name of files to my program. My program has already running and I dont want my program to be executed again because my program use mutex and uac.
I am using delphi, if you have clues, reference or sample code, really appreciate.

Besides using launcher app like Ignacio suggests you could use DDE to contact already running applications. Another option is writing your own shell extension. You can read more about it here.

Use a helper app that starts the program if necessary, then sends the filenames to be processed via a mailslot.

Related

Is any way register shell extension by Regasm.exe without codebase?

this is problem.
I developed a shell extension of Shell Context Menus.
(use SharpShell, enter link description here)
I can register it by using regasm.exe with "/codebase" attribute.
And without this attribute the shell extension doesn't work.
But this attribute let me can't update the .dll file without reboot explorer.
Even worse, can't delete .dll file after that unregistered and reboot PC (in windows 8).
So, did that have any way to solve this problem?
By the way, if anyone can tell me what is "/codebase" actually doing?
(I saw MSDN already, but totally can't understand.)
The only solution is to enumerate the handles created by explorer.exe and filter them by the target file, which is your own locked dll file. Then you can remove the handle.
It would require P/invoke if you will use C#, or handle.exe by Sysinternals if you will use any scripting language during installation. However, removing handles in the background of the application that has the handle is an unsupported way and may result with undefined consequences.

How to allow an executable file to launch a pdf when the sandbox Acrobat Reader XI blocks it

My setup.exe installs several files including an executable.
When I ask this executable to launch a help file with "ShellExecute ... pdf", it happens nothing visible, but in the task manager, I can see that Acrobat Reader has been launched.
But it is stuck and can no more be launched, even manually untilĀ  I have removed the frozen process.
What is the solution?
Almost certainly the issue is as discussed in the comments. Namely that the installer program runs as elevated administrator, and modern Acrobat Reader won't open documents when the process is executed as elevated administrator.
You can check this yourself quite easily with a simple program that contains a single call to ShellExecute to open the document in question. Run the program as standard user and see what happens with the call to ShellExecute. Then run the program as administrator and check that the document fails to open.
The solution is for you to run the program as standard user. That's not an easy thing to arrange from an elevated process. It involves quite a lot of furkling around. This MSDN article is the best source of information that I know of on the topic: How do I start a program as the desktop user from an elevated app? The code supplied is in C++ but since it is almost entirely Win32 API calls it should be a trivial conversion task.

not enough space for environment appears when executing ".exe" file

I am trying to use an application called CLUT.exe which is an old application for MS-DOS that can be used to reindex NTX files for DBF databases.
(This is not the main topic, but I am just writing this if someone wants to test the app and don't trust at all about the content).
The problem starts when trying to run the command line version through console (cmd.exe) and this error appears:
C:\>CLUT.exe [arg1] [arg2] [arg3]
run-time error R6009
- not enough space for environment
So, according to what I've searched, this could be a possible solution:
http://support.microsoft.com/default.aspx?scid=kb;en-us;230205
but it doesn't work and every alternative that I found to solve this over the internet is the same.
Another alternative could be to make right-click in the .exe file, go to Properties then Memory tab and increase the Initial environment memory from Auto to the max value but it doesn't work too.
Well, I am stuck and no "possible" solution is working for me. If someone is interested, knows more about this issue and want to test, you can download the application from here (click "Free Download" green button):
http://www.filebasket.com/free/Development-Clipper-programming-language/clut-exe/13996.html
or directly from my DropBox:
https://dl.dropbox.com/u/15208254/stackoverflow/clut_214.rar
Just to know, I am using Windows 7 and the CLUT.exe application is a Clipper based app (old programming language) that may run under windows console (cmd.exe).
Wikipedia does mention other dos emulators but, oddly, doesn't mention BOCHS.
Reindexing NTX files is not a difficult thing to do, and can be done with tools other than CLUT. For example, many of the utilities listed on this part of Download32 could be used. Otherwise, you could write your own using Harbour Project or xHarbour. Or contact me off list and I'll cook up something in Clipper 5.3.
LATER
If I read the README correctly for CLUT, it's a replacement for the DBU utility that comes with Clipper 5.x. I can supply you with a build of that if you're unsuccessful with other approaches.

Can I make my Delphi App start at a specific time (like 12:00AM), without the application running?

I saw an installed application, that feeds some XML data from the vendor's website and displays it in the Main Form window. Simple stuff, I suppose, but whgat I noticed was that, even when I close the Application in the system tray, tomorrow morning (at exactly 12:00AM) it pops ups again! This is so cool. I am not sure that it was written in Delphi, probably some .NET IDE or somehting.
Can Delphi XE2 achieve this? If so, how can I get that to work?
Windows can achieve this: Administrative Tools -> Task Scheduler
If you need to add / manage Task Scheduler in your delphi application, there is a JCL library specially created for that :
http://wiki.delphi-jedi.org/wiki/JCL_Help:JclTask.pas
There is no documentation but you can see the source code and use the TJclTaskSchedule to add executing your own application in Task Scheduler.
To automatically create a scheduled Task either use the "schtasks.exe" command line utility that comes with Windows or an interface to the Task Scheduler API. An alternative to the JCL library is the commercial "VCL Scheduling Agent" component for Delphi.

How to debug .exe started by another .exe in Delphi

I want to debug App2.exe, which is started by App1.exe. If App2.exe were a dll I could specify a host application, but this doesn't seem to work with an .exe.
I now use 'attach to process', but this is useless if App2.exe crashes before I do that.
Is there a way to do this with having to attach to the process manually?
Set the "debug spawned processes" debugging option. It is off by default. When App1 starts the new process, the debugger will pause. If the debugger isn't already attached to the new process automatically, attach to it, and then resume running it.
No, but there might be a way to get it to attach properly. Find something that you know will happen in App2 soon before the crash point, and have it pop up a modal dialog box at that point. Then it won't continue until you dismiss it, giving you time to attach the debugger.
I guess you could launch app2.exe yourself and pass any necessary command line parameters to it.
If you're using windows, there is a built in support for it.
basically, you can tell the windows loader to launch some other process whenever a specific process is launched. for example, you can tell windows to always launch winword.exe whenever you click on notepad.exe
you can use this ability in order to automatically launch a debugger whenever you start your process (this is why this feature was originally introduced, however you are not restricted to launch only debuggers :))
You can read exactly how to do it here.
You can also download the debugging tools for windows package and use GFlags to do it for you.
If both apps are yours and you have the code than I propose the following:
Make a debug mode for both apps. Use external inc file for instance
Start two IDEs and load each app in its own IDE. Build in debug mode
If done right you can now debug the internal communication between apps
I have a project where a server spawns multiple exe worker processes that host each its own dll module. I have a debug mode in which I can specify which dll will be loaded and I can have both processes running and communicationt in between from IDEs. It is the best way I have found so far.

Resources