delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/04/23/15:19:05

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS
X-Spam-Check-By: sourceware.org
Date: 23 Apr 2009 19:18:40 -0000
To: cygwin AT cygwin DOT com
Subject: detecting program invocation from a symbolic link
Encoding: 8bit
From: ncokwqc02 AT sneakemail DOT com
Message-ID: <14974-38810@sneakemail.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

I have some C++ code that runs from the command line in a console shell. It is designed to behave differently depending on whether it was called directly by name or by a differently named symbolic link. This is easy to check under Unix because argv[0] contains the name of the first command line argument, which is either the executable name or the name of the link.

This doesn't work under Windows, however, because argv[0] always contains the name of the program being called whether it is actually on the command line or via a link.

Even symbolic links created using 'ln -s' under Cygwin behave this way. I'm wondering if there is a way around this problem. In other words, any way for my C++ program to detect the name of the symbolic link if one was used to invoke the executable.

Thanks,

J. J. Ottusch

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019