how can i get the file name from explore?

This is a discussion on how can i get the file name from explore? within the C++ Programming forums, part of the General Programming Boards category; Hey people kind of new to c++ still I made a notepad type program that starts when you click on ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    8

    Question how can i get the file name from explore?

    Hey people
    kind of new to c++ still
    I made a notepad type program that starts when you click on a file that opens with it ".txt " can some one plz tell me how to get the file name from win explore i.e. I want to get the name of the file that was clicked on that started the program i no it's not hard Iíve just never done it before so I don't no Thanks...

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    8
    thought people here new c++?
    every one doing windows programs knows this come on
    i googled it for over an hour i dont no what to search for

  3. #3
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Then why not look at what they are doingXD? sorry i've been looking for days on stuff I want to know, 1 hr nothing.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    52
    The first thing I'd try is checking argv[1] - in normal console mode, argv[0] is the program name, and argv[1] is the first argument passed. The Windows GUI typically invokes programs by calling them as "program_name $1" where $1 is replaced with the file name of the clicked file.

    Also, for future posts - I'd bet Saturday morning isn't the best time to catch folks around here, and the sort of hostility apparent in your second post is NOT gonna win friends on any board I've ever been on.

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    8
    Quote Originally Posted by adr
    Then why not look at what they are doingXD? sorry i've been looking for days on stuff I want to know, 1 hr nothing.
    maybe you don't no what you're looking for
    its not the same when you type'n in random words
    maybe you should try posting or something

    Quote Originally Posted by Stuka
    The first thing I'd try is checking argv[1] - in normal console mode, argv[0] is the program name, and argv[1] is the first argument passed. The Windows GUI typically invokes programs by calling them as "program_name $1" where $1 is replaced with the file name of the clicked file.

    Also, for future posts - I'd bet Saturday morning isn't the best time to catch folks around here, and the sort of hostility apparent in your second post is NOT gonna win friends on any board I've ever been on.
    stuka big help you saved the day unlike ard i ment adr
    Last edited by crack_head!; 01-14-2006 at 08:59 AM.

  6. #6
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    1st off, post something someone all ready may have ask in the past is a wast of space and makes thing really much more harder to finde. 2end I do just put ramdom things frist to get start, like right now I was looking for "how to close a background proesses" then I when from there to TerminateProcess() witch was somthing I needed. So maybe I need sleepXD LOL night.

  7. #7
    Registered User
    Join Date
    Jan 2006
    Posts
    8

    Thumbs down

    i did a check and did not see anything
    so i posted lol i did a search of the board
    you are wast'n alot more space and make'n it alot harder for people
    what if some people have the same problem
    now they have to scroll down past all you're junk
    and they will all see what a no life you are
    anyone would no that
    maybe you should get alife and stop posting off topic

    "its not the same when you type'n in random words"
    i was talking about myself
    Last edited by crack_head!; 01-14-2006 at 10:08 AM.

  8. #8
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Did you read Stuka's post?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #9
    Registered User
    Join Date
    Jan 2006
    Posts
    8
    Quote Originally Posted by adrianxw
    Did you read Stuka's post?
    Yup I think that will help me find what I was Iím looking for
    I just donít no how to use it but I think I can find it
    If you no how. I could really use some help on how to use that
    Iíve use the argv with cmd but WinMain is much different
    A sample code would be nice if you could
    or maybe some keywords for the google
    thanks...
    Last edited by crack_head!; 01-14-2006 at 11:39 AM.

  10. #10
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Using windows programming:

    Code:
    	int numElements;
    	LPWSTR * szName;
    
    	szName = ::CommandLineToArgvW
    		 (::GetCommandLineW(), &numElements); 
    
    	// szName = ::CommandLineToArgvW
    	//	(szCmdLineofWinMain, &numElements); 
    
    	::MessageBoxW(
    		 HWND_DESKTOP, 
    		 szName[0], 
    		 szName[0], 
    		 MB_OK);
    
    	::LocalFree(szName);
    http://msdn.microsoft.com/library/de...ommandline.asp
    http://msdn.microsoft.com/library/de...linetoargv.asp
    Last edited by Tonto; 01-14-2006 at 01:07 PM.

  11. #11
    Registered User
    Join Date
    Jan 2006
    Posts
    8

    Thumbs up

    thank you Tonto i'll try it on sunday but i think its just what i was looking for

  12. #12
    Registered User
    Join Date
    Jan 2006
    Posts
    8
    no problems now
    got it working Thanks to you Tonto

  13. #13
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    For the love of dog, learn to spell just a bit!

    Do you have some issue with the letter 'k'? Perhaps you bro e it off your eyboard?

    'no' is not 'know' and 'new' is not knew.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  14. #14
    Registered User
    Join Date
    Jan 2006
    Posts
    8
    lol had some drinks then posted
    next time I will take more time when drinking and posting

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21