Path Problem

This is a discussion on Path Problem within the C++ Programming forums, part of the General Programming Boards category; ok im trying to create a menu program that will launch as soon as my pen drive is connected...problem is...while ...

  1. #1
    Fallen AndyBomstad's Avatar
    Join Date
    Jan 2005
    Posts
    52

    Path Problem

    ok im trying to create a menu program that will launch as soon as my pen drive is connected...problem is...while writing my code i have no idea what the Drive letter for my pen drive is until i get to that pc...

    Obviously i dont want to open Dev C++ just to change the code to match that pc.. so is there a way to make a path that kinda either searches all the drives for the Executable or somthing...?

    Code:
    int sel = getch();
            if(sel == '1')
            {
               cls
               system("..\\Linker\\Apps\\login2.exe");      //activates the .exe file for Login2
            }
            if(sel == '2')
            {
                   cls
                   system("..\\Linker\\Apps\\Warrior.exe"); //activates the .exe file for Warrior
            }
            if(sel == '3')
            {
                   cls
                   system("..\\Linker\\Apps\\PCLock.exe"); //activates the .exe file for PCLock 
            }
            main();
    that is a piece out of my code... i tried using ".." as the begining of the path but the complier didnt like that, anyhelp would be great

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    If you begin a path with a \ ("\\) it indicates the current drive. But that depends on where the program is called from not the programs location.

  3. #3
    Fallen AndyBomstad's Avatar
    Join Date
    Jan 2005
    Posts
    52
    ** Yep that works i just changed the path to "\\Linker\\Apps\\programname.exe" and it worked since both the main EXE and the ones its calling are both on the Pendrive it automaticly starts from that drive letter.. Thanks
    Last edited by AndyBomstad; 05-05-2005 at 01:56 PM.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    I would say yes.
    The only time it wouldn't work would be if the current drive were different for example if you were in a command prompt at the c:\windows prompt and you started the program on the pen drive by typing it into the command prompt the current drive would be C:.

  5. #5
    Fallen AndyBomstad's Avatar
    Join Date
    Jan 2005
    Posts
    52
    yeah thats true, but the program is made to Autorun as soon as the pendrive is connected, or if you start it from within the folder in the pendrive

    its basicly made so that i can pop my pen drive in and choose one of my most used programs to work with right there, i guess im just getting to lazy to click about 4 times lol!

  6. #6
    Fallen AndyBomstad's Avatar
    Join Date
    Jan 2005
    Posts
    52
    alright well now im stuck on the autorunning from the pendrive....anyone got any ideas?
    i already made the Autorun.inf file, but i dont know how to go aobut getting it to start as soon as the pen drive is plugged in....lol this is sooo off the subjest of c++ now lol

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Do you have to enable play for USB devices? Maybe its not enabled by default like CD-ROM drives.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  2. Shortest path problem
    By Digitalxero in forum C++ Programming
    Replies: 0
    Last Post: 10-25-2005, 06:32 PM
  3. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 02:04 AM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 09:37 AM
  5. Strange problem with fts_open call
    By jhopper in forum C Programming
    Replies: 0
    Last Post: 02-26-2002, 12:01 AM

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