Introduce a powerful API function shellexecute

zhaozj2021-02-11  268

Introduction to a powerful API function shellexecute compiles Zhao Xiangning issues: I use MFC to write an app, ask for the About dialog box to display logo, company name, address, and company URL links. After using the user to click the URL link, start the browser to access the web page, the hot link in this dialog box makes a lot of color. The way I pondering is to get the name of the default browser from the system registry to find the .htm or .html file, this seems to have a lot of work to do. Also, if the browser has already opened, always start a new instance instead of an instance of the current existing. I want to find an easy way, but I have checked the relevant information, no gain, please advise. Workaround: If there is such an API function, how good: OpenThishereURLForMenowplease (), the problem is not solved! ! I tell you, have, but it is not the function you imagined. So far, there is no mention of such a useful function in the documentation, which can open any file on the desktop and open the Internet URL. The only reference I can find is to mention this function in Microsoft® Access KnowledgeBase. This incredible function is: Shellexecute, replaced Winexec. You can give it the name of any file, it can identify and open it. For example: Shellexecute (NULL, "Open", "Iloveu.bmp", NULL, NULL, SW_SHOWNORMAL); open a bitmap file called Iloveu.bmp with a default bitmap editor, this default bitmap editor It may be Microsoft Paint, Adobe Photoshop, or Corel PhotoPaint. For detailed usage information about Shellexecute, you should refer to the relevant information, it is important that you know that this function can open any file, or even a desktop and URL shortcut (.ink or .url). SHELLEXECUTE parses all content in the system registry hkey_classes_root, determine the execution program, and start a new instance or use DDE to connect the file name to an open instance. Then, SHELLEXECUTE returns an instance handle of the application that opens the file. More wonderful is that shellexecute can not only open the file on the machine, but also open the Internet site address. For example: Shellexecute (Null, "Open", "http://www.microsoft.com", null, null, sw_shownormal; this code allows you to access Microsoft's homepage. When shellexecute encounters "HTTP:" in front of the file name, it is possible to determine that the file to be opened is a web file, start Internet Explorer or Netscape Navigator or any other browser you use to open the file. Shellexecute can also identify other protocols, like FTP, Gopher. Even "Mailto", if the file name points to "Mailto: Zxn@hq.cninfo.net", which launches an email program and opens a new message to be edited. In short, the shellexecute function is so simply open disk files and Internet files. If the second parameter "open" is changed to "Print" or "Explore", Shellexecute will be able to print the file and open the folder.

转载请注明原文地址:https://www.9cbs.com/read-3896.html

New Post(0)