Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3EA80ED1.4030303@verizon.net> Date: Thu, 24 Apr 2003 09:20:33 -0700 From: Tron Thomas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cygwin Subject: Re: How to parse windows command line Content-Type: multipart/related; boundary="------------080301020500010408000405" X-Authentication-Info: Submitted using SMTP AUTH at pop017.verizon.net from [4.65.3.2] at Thu, 24 Apr 2003 11:20:29 -0500 --------------080301020500010408000405 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Here is the code that is relevant to the problem: int WINAPI WinMain ( HINSTANCE, HINSTANCE, LPSTR pszArguments, int ) { std::string strTitle(pszArguments); ... If I compile this with the Borland compiler and then lauch the program from bash using: ./Program.exe Filename, then pszArguments (and consequently strTitle) just equals "Filename". If I compile with Cygwin and launch the file the same way, pszArguments equals something like: "Directory\\Directory\\Program.exe\" Filename " pszArgument doesn't even contain the full path to the executable. It starts partway through the path name, containing only the ending portion of one of the directories in the path name. I don't really care about the executable path name. All I want is the filename, like what I get when I compile with Borland or Microsoft. Elfyn McBratney wrote: >>>>I have written a Windows application that expects a file name as a >>>>command line argument. If I compile the program with a either the >>>>Borland or Micrsoft compilers I get just the file name as the command >>>>line argument when I run the program. >>>> >>>>However if I compile the program with the Cygwin compiler I get some >>>>like the following for the command line argument when I run the program: >>>> >>>>"Directory\\Directory\\Program.exe\" Filename " >>>> >>>> >> >> >> >>Need just a bit more information that that. What is the code you are using? >>WinMain? >> >> >> > > >>>>This is make things akward. I'm not sure why Cygwin is doing this when >>>>other compilers don't. >>>> >>>>Does Cygwin provide an API or other strategy to deal with this scenario? >>>> >>>> >> >> >> >>Well, again that depends. My name is luke and I need to see the source. ;-) >>For example, this mingw (AKA Windows native) application >> >>--- CUT HERE --- >>#include >> >>void >>main (int argc, char **argv) >>{ >> printf ("My name is %s,\nHello, %s\n", >> argv[0] /* The program (executable file) name */, >> argv[1] ? argv[1] : "No name" /* First argument (if) passed to >>the program */); >>} >>--- CUT HERE --- >> >>Will print out the name of the program. On Cygwin >> >> >> > > >>>>My name is ./test1 >>>>Hello, Zippy >>>> >>>> >> >> >> >>and on Windows (from a command prompt) >> >> >> > > >>>>My name is G:\Cygwin\root\tmp\test1.exe >>>>Hello, George and Bungle >>>> >>>> >> >> >> >>Elfyn >> >> >> > --------------080301020500010408000405--