Thread: Getting the selected file?

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    12

    Getting the selected file?

    Anyone know which function to call to get me the handle of the file currently selected? Or any information about it at all?

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    CreateFile or OpenFile might help you.
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    12
    They would, but I need to find which file to Open/Create, first, that's the problem.

  4. #4
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    FindFirstFile and FindNextFile might be of some use
    http://www.adrianxw.dk/SoftwareSite/index.html
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  5. #5
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    Do you mean selected via the default open dialog?

    If so, you want to look at the GetOpenFileName function.

    The path is pointed to by lpstrFile in the OPENFILENAME struct
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    12
    No, I mean, when you're on the desktop, you have no windows/dialogs open, and you select a file, by single-clicking on it. It highlights blue. Windows has to keep the handle for that file somewhere. I just need to know where.

  7. #7
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I don't think a handle is created for it until you try to open it. Highlighting it probably does nothing "under the hood".
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    12
    Well, windows has to have some way of figuring out which file you have selected if you open it via the enter key... it's obviously stored SOMEWHERE... there's no function to get any information about the file?

  9. #9
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Not in the way you're talking about. The other methods suggested here will though and knowing the Windows API there's probably more ways of getting all sorts of information too.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  10. #10
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    Quote Originally Posted by Erondial
    Well, windows has to have some way of figuring out which file you have selected if you open it via the enter key... it's obviously stored SOMEWHERE... there's no function to get any information about the file?
    When you select a file using explorer.exe, only that program knows where it is. Since explorer.exe is a separate application, you can't find out directly what file is selected. However since it probably uses a ListView control, you could do some complicated DLL injection and message hooking, but I don't think it's worth it.

  11. #11
    Registered User
    Join Date
    Oct 2005
    Posts
    12
    Okay. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  2. file processing updating record error
    By uuser in forum C Programming
    Replies: 2
    Last Post: 04-27-2003, 12:13 AM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM