CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2006
    Location
    Dublin, Ireland
    Posts
    42

    Reading selected file in Windows Explorer

    Hi there,

    can any one help me to read the selected file through VB?

    All I want to do is make multiple copies of a selected file from windows explorer. I mean if I click on a file in windows exp. and click right mouse button there will be my VB program select that then multiple copies should be made.

    thanks in advance
    regds.

  2. #2
    Join Date
    Jul 2006
    Location
    Dublin, Ireland
    Posts
    42

    Re: Reading selected file in Windows Explorer

    I want to read file name with full path from the buffer and make multiple copies.

  3. #3
    Join Date
    Jul 2006
    Location
    Dublin, Ireland
    Posts
    42

    Re: Reading selected file in Windows Explorer

    can any one help me on this? thanks in advance

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Reading selected file in Windows Explorer

    Let's see. I don't think there is a direct VB solution....

    First you have to add an item to the context menu (look here):
    http://weblogs.asp.net/stevencohn/ar...07/406098.aspx

    This describes how to add a command to the context menu.
    You would have to use the name of your VB program and pass it the filename as command line parameter "%1".
    In you VB program you use Command$ to access this filename and do with it whatever you like.

  5. #5
    Join Date
    Jul 2006
    Location
    Dublin, Ireland
    Posts
    42

    Re: Reading selected file in Windows Explorer

    Thanks Wof.

    I am fine with adding item to context menu by updating the registry.

    My problem is when I select any file in windows explorer, I want to read that just selected file name with complete path of that file through VB.
    I think there will be WIN API function for this, but I don't know which one it is and how to use it Please help.

    thanks in advance
    with regards

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Reading selected file in Windows Explorer

    Glad taht you succeeded creating new context menu items. I didn't.

    Which windows version do you use?

    But if you succeed, you are almost there:
    Assuming your VB program is called DoIt.exe, then your command key entry must be: DoIt "%1", the %1 passing the complete filename to your DoIt.exe.
    That is, when you right click a filename and chose 'DoIt' for that file, your program is startet and the filename passed as a command line parameter.
    The passed parameter is available in Command$, a predefined variable containing everything what goes after the program call.
    Hope that helps.
    And now my messing around with the registry got me stuck. My folders do not open anymore by default.

  7. #7
    Join Date
    Jul 2006
    Location
    Dublin, Ireland
    Posts
    42

    Re: Reading selected file in Windows Explorer

    Hi WoF brilliant, I got it.

    BTW I have Win xp SP2.

    thanks for your help

    regds.

  8. #8
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Reading selected file in Windows Explorer

    Fine.

    Would you mind telling my how you produced the menu entry?
    I also have XP SP2 and followed the instructions from the link i supplied, but did not succeed in getting a new menu entry. What have I missed?

  9. #9
    Join Date
    Jul 2006
    Location
    Dublin, Ireland
    Posts
    42

    Re: Reading selected file in Windows Explorer

    try the article below, clearly described. I used the same.

    http://www.jfitz.com/tips/rclick_custom.html

    BTW any idea of adding sub menu's to the context menu.

    I mean like 'Openwith', then sub menu, where we can see list of programs, like that.

    thanks in advance

  10. #10
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Reading selected file in Windows Explorer

    Yes, great. Got it. I just missed the '*' as a separate key.

    Concerning Submenus... I'm not sure about that.
    There is always the 'Send to' submenu to learn something about. I may have a look over the weekened.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured