Start external exe within own process

我怕爱的太早我们不能终老 提交于 2019-12-11 03:58:47

问题


I have a VB6 executable we use as a Starter executable for our real program.

The problem is that windows 7 shows a new icon in the taskbar for the new process, instead of the one i clicked on to start my program (of course, because the starter exe has already ended, and the new exe seems to be a new program).

Currently I use the Shell object to start the other exe. Is there a better way to do it from vb6, maybe by using a native C function with declare that does start an exe in the current process, without spawning a new process?

EDIT:

Thanks to atzz for the great information about Application Model IDs. I now have a shortcut to my app starter with a well defined id, and my app also sets the ID when started, and is now accesssible beautifully from the right icon in the toolbar. However, two problems persist:

  1. The app is a Java App started with Exe4J, and I don't have any chance to set the AppID before Exe4J shows the splash screen, so while showing the splash screen there is a second icon in the taskbar.

  2. If I don't manually drag my starter app icon from the Desktop to the toolbar, but instead use my apps icon and set it to be "sticky", the real app is sticked, and not the launcher.

Both problems would be beautifully solved if my launcher would start the app from within its own process. I heard something of using exec() instead of fork() for linux programs to achive this... is there something similar for windows?


回答1:


I believe there is a way to accomplish what you need via Windows 7 taskbar API, though I never did it myself and thus don't remember clearly enough what I've read on the subject. Look around the Application ID concept.

Some links:

  • Developing for the Windows 7 Taskbar – Application ID
  • Inside Windows 7 - Introducing The Taskbar APIs



回答2:


If the problem is the icon, why not give both programs the same icon (and the same App.Title). Then the user won't be able to tell the difference between the two taskbar entries. Presumably they aren't both visible at the same time.

Alternatively set your starter app not to appear in the taskbar (Form property ShowInTaskbar = False in the design view)



来源:https://stackoverflow.com/questions/5115018/start-external-exe-within-own-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!