Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. noob alert part 2 !! ShellExec function.

noob alert part 2 !! ShellExec function.

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    no_life
    wrote on last edited by
    #1

    hello, I am a begginer. i'm experimenting with a shellexec funtion to try and launch various things from my simple dialog based MFC application. Things like web pages, exe's, and files. I plan on just mapping them to a simple button. can anyone explain (in newb terms) how to get this function to work properly?? How to implement it and where exactly im supposed to add this code?? I would really appreciate any help, Thanks

    A 1 Reply Last reply
    0
    • N no_life

      hello, I am a begginer. i'm experimenting with a shellexec funtion to try and launch various things from my simple dialog based MFC application. Things like web pages, exe's, and files. I plan on just mapping them to a simple button. can anyone explain (in newb terms) how to get this function to work properly?? How to implement it and where exactly im supposed to add this code?? I would really appreciate any help, Thanks

      A Offline
      A Offline
      Andrew Walker
      wrote on last edited by
      #2

      In the resource editor, add a button to the dialog Double click on the button. This adds a method to the dialog class Add code for the handler. From MSDN: HINSTANCE ShellExecute( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd ); hwnd - 0 - don't worry about the parent window, set to NULL lpOperation - "open" - open something lpFile - "your.file" - the file or URL you want to open lpParameters - "" - unless you need to pass in cmd line params lpDirectory - "" - unless you care what directory the launched app starts in nShowCmd - SW_SHOWNORMAL - this will be okay most of the time ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL);


      If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

      N 1 Reply Last reply
      0
      • A Andrew Walker

        In the resource editor, add a button to the dialog Double click on the button. This adds a method to the dialog class Add code for the handler. From MSDN: HINSTANCE ShellExecute( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd ); hwnd - 0 - don't worry about the parent window, set to NULL lpOperation - "open" - open something lpFile - "your.file" - the file or URL you want to open lpParameters - "" - unless you need to pass in cmd line params lpDirectory - "" - unless you care what directory the launched app starts in nShowCmd - SW_SHOWNORMAL - this will be okay most of the time ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL);


        If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

        N Offline
        N Offline
        no_life
        wrote on last edited by
        #3

        hi, thank you very much for the info! you got me on the right track.. however when i compile i get an error that reads: error C2373: 'ShellExecuteA' : redefinition; different type modifiers i dont know if i put all of the code in the right spot, i added it all under the button function:

        void CShell2Dlg::OnButton1() 
        {
        	// TODO: Add your control notification handler code here
        HINSTANCE ShellExecute(
        HWND hwnd, 
        LPCTSTR lpOperation,
        LPCTSTR lpFile, 
        LPCTSTR lpParameters, 
        LPCTSTR lpDirectory,
        INT nShowCmd
        );
        ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL); 	
        }
        

        --later

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups