CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    executable behaving differently when launched via shortcut?

    I have a VC++ (VS2022) dialog based application that uses third party charting software(AES Chart Director).
    The application is iterative and after each iteration updates a chart with a new data point. What is driving me nuts is this:

    If I run the app from within the VS2022 IDE in debugging mode or without debugging mode the app displays the charts correctly after each iteration.

    If I go directly to the executable in the debug directory and launch it wit a double click the app displays the charts correctly after each iteration.

    However, if I set up a shortcut on the Windows10 task bar and launch it in any manner (open, run as administrator, or just clicking on the task bar icon) the chart only appears after the last iteration ie not after any of the non-terminal iterations.

    Anyone have any insight - many thanks in advance.
    Last edited by jim enright; October 25th, 2022 at 09:34 PM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,313

    Re: executable behaving differently when launched via shortcut?

    I would first check all the paths used in your solution, particularly the ones concerning the third party parts.
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,230

    Re: executable behaving differently when launched via shortcut?

    I can guess you are using or passing to the third party library paths relative to the application/process current directory (e.g. ".\data", "..\data" or just the file name). The current process directory is not obviously the same as the directory in which the application executable is located. Moreover, it can be changed at run-time. For example, if launch the application from Visual Studio, the current process directory is set to the solution folder.

    The solution is to provide the full path (e.g. "c:\work\theapp\data"). Of course, hardcoding paths is a bad idea, but you can construct them at run-time. Depending of what practically must be achieved:
    • call GetModuleFileName to find the folder in which the executable is located
    • or use a special (known) folder, as for example AppData
    • or show a Select Folder dialog, then provide the path selected.

    I have attached here a demo project which hopefully can help you: PathsInfo.zip
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpert.ro/blog/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured