dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: [RESOLVED] Reading a run parameter

  1. #1
    Join Date
    Apr 2007
    Posts
    160

    [RESOLVED] Reading a run parameter

    I have my MFC app set to start whenever I right click on a folder and select "MyApp" from the menu. How do I get the name of the folder that I right clicked on to start my application?

    Thanks
    Zapper

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,624

    Re: Reading a run parameter

    Use GetModuleFileName function which retrieves the full path and file name for the file containing your exe.
    Use then PathRemoveFileSpec to obtain the folder path from the full path name.
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2009
    Posts
    10

    Re: Reading a run parameter

    Today, we are living in an era of the Internet where online project management software serves as a great tool to help us complete projects on time. Such software is the simplest tool that helps the project managers plan and manage different tasks that are involved in each project.

    For more information about , visit on link: http://www.project-drive.net/

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Reading a run parameter

    Quote Originally Posted by Barriebyrnes View Post
    Today, we are living in an era of the Internet where online project management software serves as a great tool to help us complete projects on time. Such software is the simplest tool that helps the project managers plan and manage different tasks that are involved in each project.

    For more information about , visit on link: http://www.project-drive.net/
    Please stop spamming Codeguru. Nobody cares about your project-drive.

  5. #5
    Join Date
    Apr 2007
    Posts
    160

    Re: Reading a run parameter

    Quote Originally Posted by VictorN View Post
    Use GetModuleFileName function which retrieves the full path and file name for the file containing your exe.
    Use then PathRemoveFileSpec to obtain the folder path from the full path name.
    Hi Victor,
    That would give me the path to where my app is running from but what I want is the path to the directory that was right clicked upon.

    Thanks
    Zapper

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,560

    Re: Reading a run parameter

    I'm not exactly sure what you mean by right clicking on a folder to start an app, but perhaps you're looking for GetCurrentDirectory();

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,624

    Re: Reading a run parameter

    Quote Originally Posted by zapper222 View Post
    I have my MFC app set to start whenever I right click on a folder and select "MyApp" from the menu ...
    Quote Originally Posted by zapper222 View Post
    Hi Victor,
    That would give me the path to where my app is running from but what I want is the path to the directory that was right clicked upon...
    1. What is the Application you make a "right click on a folder and select "MyApp" from the menu"? Is it Windows Explorer or some other?

    2. What is the *menu* containing "MyApp" item? Who created it? Who and how handles it?
    Victor Nijegorodov

  8. #8
    Join Date
    Apr 2007
    Posts
    160

    Re: Reading a run parameter

    => GCDEF
    No GetCurrentDirectory() doesn't work.

    =>Victor
    Think of it like when you want to search a directory, you right click on the directory, and select Search...
    I have modified a registry setting so that when you right click on a folder my application is one of the menu items you can select. Now when my application starts I want the directory that the user right clicked upon.

    Zapper

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,624

    Re: Reading a run parameter

    Quote Originally Posted by zapper222 View Post
    Think of it like when you want to search a directory, you right click on the directory, and select Search...
    I have modified a registry setting ...
    1. Again: What is the Application you make a "right click on a folder and select "MyApp" from the menu"? Is it Windows Explorer or some other?

    2. Which "registry setting" did you modify and what for?
    Victor Nijegorodov

  10. #10
    Join Date
    Apr 2007
    Posts
    160

    Re: Reading a run parameter

    The application is an MFC dialog application that I wrote.
    I want to identify the folder that was right clicked upon.
    The entry in the registry just identifies the path to my application.

    So what I have noticed in other registry entries such as notepad etc is that the path to notepad is provided and a variable is placed at the end that would identify the filename.
    ie c:\windows\notepad.exe "%1"

    So if I make my registry entry read:
    c:\windows\mydir\myapp.exe "%1"
    When my application starts where would I find the value of %1...where does an mfc dialog application store this when it starts up ?

    Zapper

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,624

    Re: Reading a run parameter

    Quote Originally Posted by zapper222 View Post
    ...
    So if I make my registry entry read:
    c:\windows\mydir\myapp.exe "%1"
    When my application starts where would I find the value of %1...where does an mfc dialog application store this when it starts up ?
    Well, your explanation is very poor again...
    However, if you only want to get the value of "%1" parameter of the command line started your App then have a look at MFC class CCommandLineInfo or/and CWinApp::m_lpCmdLine member or/and GetCommandLine / CommandLineToArgvW Win32 API functions
    Victor Nijegorodov

  12. #12
    Join Date
    Apr 2007
    Posts
    160

    Re: Reading a run parameter

    It was a command line argument I was looking for and m_lpCmdLine was what I needed.

    Thanks Victor !

    Zapper

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)