Those pesky command lines...

This is a discussion on Those pesky command lines... within the Windows Programming forums, part of the Platform Specific Boards category; Hello, Just a quick question. A program I've made doesn't take kindly to long filenames when passed to it by ...

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266

    Unhappy Those pesky command lines...

    Hello,

    Just a quick question. A program I've made doesn't take kindly to long filenames when passed to it by Explorer (The little tyke loves sellotaping it all together with speech marks yet MS decided CreateFile shouldn't parse them out ). Is there a simple way of fixing the string?

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    So you have a string like ' "file with long filename.txt" ' and you want it to become 'file with long filename.txt'? Try this:

    Code:
    char * RemoveQuotes(char *lpString)
    {
        lpString++;
        lpString[lstrlen(lpString)-1]=0;
        return lpString;
    }
    Approximate, and likely will cause a memory leak, or access violation now that I think about it. Hmmm.

    Code:
    void RemoveQuotes(char *lpString)
    {
        int size=lstrlen(lpString);
    
       for (int i=0;i<size;i++)
       {
           lpString[i]=lpString[i+1];
       }
       lpString[size-2]=0;
    }
    That should work fine I think.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ridding Myself of a Pesky Virus/Spyware/Whatever
    By golfinguy4 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-22-2006, 01:12 PM

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