windows - How to retrieve the first argument when there is no Main()?

08
2014-07
  • Travis Banger

    When the user drops a file icon on top of my application's icon, I am able to retrieve the filepath of the dropped file. It is contained in args[0].

    How can I retrieve that filepath when there is no Main()?

    IOW: My latest app is not console-based.

  • Answers
  • heavyd

    You can use the Environment.GetCommandLineArgs() function to get the command line arguments at any time in your application.


  • Related Question

    issues with applications that use WPF on Windows 7
  • jaminto

    I reinstalled windows 7 enterprise a couple of weeks ago, and ever since, I've had issues with programs that use WPF to display UIs. You may say "these are just bugs in the programs", but since the symptoms are both identical and both programs use the "new new" WPF technology, I can only assume its all related.

    When using Windows Live messenger 2011, the chat window will get in a state where choosing other tabs to chat with other users will not work. It changes the tab state indicating that it has switch to the other tab, but the content of the chat window is still the previous chat. After some period of use, I will give the live messenger window focus, and the whole window content will be black. This happens with both the chat windows and the main live messenger window.

    Visual Web Developer Express (the lite version of VS2010), will get into a state where scrolling stops working. Clicking on tabs to navigate to other open documents will have no effect. shortly after (like 30-90 seconds) the whole application will crash. The entire document editing frame will also go black, while the solution explorer, output window, and other panels within the app will continue to function properly.

    I have an NVIDIA Quadro FX 570 video card on my desktop with the latest drivers.

    Are there any tools I can use to debug this issue further? Is there a way to reinstall or recalibrate(?) WPF? Any other ideas?


  • Related Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.