- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use kernel32 use dfwinty implicit none character, pointer :: AppName type(T_STARTUPINFO) StartInfo type(T_PROCESS_INFORMATION) ProcessInfo logical(4) ret StartInfo%wShowWindow = 1 !SW_NORMAL StartInfo%cb = 68 !bytes NULLIFY(AppName) ret = CreateProcess(AppName, 'Notepad.exe "Filename.txt" ', NULL_SECURITY_ATTRIBUTES, NULL_SECURITY_ATTRIBUTES, .FALSE., CREATE_SEPARATE_WOW_VDM, NULL, AppName, StartInfo, ProcessInfo)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ShellExecute is for anyone. Here's the VF News article I wrote on it with an example.
Steve Lionel
Visual Fortran Engineering
Win32 Corner is a new feature of the newsletter that illustrates how to use Win32 API routines to do commonly requested tasks.
The ShellExecute API routine is handy for opening a web page, or any document using its natural editing tool. It's equivalent to right clicking on a file and selecting Open - or you can also choose the default action (whatever is listed first), Print or Edit. I've found it most useful for opening a web page with the user's default browser.
Open shellexecute.f90 and reference the numbered comments (!!1, etc.) below:
- ShellExecute is part of the Shell API and is defined in module SHELL32. You could also USE DFWIN.
- The hWnd argument is the handle of the owner's window. In a Console Application, NULL is the thing to use, but in a Windows Application you might want the main window, and in QuickWin, use GETHWNDQQ(QWIN$FRAMEWINDOW).
- lpOperation (referred to as lpVerb in newer versions of the MS documentation) is a C-string that says what to do with the file. "open" is what you'll want most often, but you could also specify "edit" or "print". If the argument is null, then the "default action" is used.
- lpFile is the thing we want to open. It could be an ordinary file, or a URL. Note the NUL-termination to make it a C-string.
- If we were opening (running) an executable file, command parameters would go here.
- You can specify a default directory if you want. NULL_CHARACTER passes the equivalent of a C NULL here.
- nShowCmd specifies how you want the window to appear. SW_SHOWNORMAL is the standard behavior, but you could also specify minimized, maximized and whether or not to hide the active window.
- If ShellExecute returns a value greater than 32, it succeeded, otherwise an error occurred. Note that ShellExecute returns immediately - it does not wait for the opened application to finish.
Try building and running shellexecute.f90 as a "Fortran Console Application". Enter a favorite URL, such as http://www.intel.com/, or the path to a file on your system, then watch it open!
For more information on ShellExecute, look it up in the Visual Fortran online documentation index.
Message Edited by sblionel on 04-28-2005 12:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page