dcsimg
Results 1 to 12 of 12

Thread: Was vb6 App launched from a shortcut or the ".exe"

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2015
    Posts
    17

    Was vb6 App launched from a shortcut or the ".exe"

    I have found a couple of threads that are close but not quite what I need.
    Can a vb6 program determine if it was started from a shortcut vs. the ".exe" file?
    If so, how can I look for that in the app?

    I update apps at times and the primary app resides on a server. People think that it will run better if they have the app on their desktop so they copy/paste it there instead of running from a shortcut, which will always points to the most recent update.

    I can look for the shortcut to see if it's there, but it doesn't tell me whether or not that was how the app was started.

    Thanks,
    Last edited by Obfuscated; Nov 28th, 2018 at 01:35 PM. Reason: Solved

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,605

    Re: Was vb6 App launched from a shortcut or the ".exe"

    I don't know whether you can distinguish between both situations.
    But you can check if App.Path is on a local drive or a network share.
    Code:
    Private Declare Function PathIsNetworkPath Lib "Shlwapi.dll" Alias "PathIsNetworkPathW" (ByVal pszPath As Long) As Long
    
    Public Function IsNetWorkPath(ByVal sPath As String) As Boolean
       IsNetWorkPath = PathIsNetworkPath(StrPtr(sPath)) = 1
    End Function
    Last edited by Arnoutdv; Nov 28th, 2018 at 07:23 AM. Reason: Replaced "A" with "W" version

  3. #3
    New Member
    Join Date
    May 2012
    Location
    42.787034,-81.176367
    Posts
    7

    Re: Was vb6 App launched from a shortcut or the ".exe"

    In Karl E. Peterson's mconsole.bas, there is the LaunchMode property;

    Read-only: Indicates whether the application was launched from within the IDE, directly from the command line, or from Explorer via a shortcut or double-click.

    Ref: http://vb.mvps.org/samples/Console/

    Joe

  4. #4
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    268

    Re: Was vb6 App launched from a shortcut or the ".exe"

    Determine if process started from shortcut

    Quote Originally Posted by Remy Lebeau
    As mentioned in an answer to a similar question, a process can find out if itself was started by a shortcut by calling GetStartupInfo() and checking for the STARTF_TITLEISLINKNAME flag. This is documented on MSDN: Read more...
    Code:
    Option Explicit
    
    Private Const STARTF_TITLEISLINKNAME As Long = &H800
    
    Private Type STARTUPINFO
        cb              As Long
        lpReserved      As Long
        lpDesktop       As Long
        lpTitle         As Long
        dwX             As Long
        dwY             As Long
        dwXSize         As Long
        dwYSize         As Long
        dwXCountChars   As Long
        dwYCountChars   As Long
        dwFillAttribute As Long
        dwFlags         As Long
        wShowWindow     As Integer
        cbReserved2     As Integer
        lpReserved2     As Long
        hStdInput       As Long
        hStdOutput      As Long
        hStdError       As Long
    End Type
    
    Private Declare Sub GetStartupInfoW Lib "kernel32.dll" (ByRef lpStartupInfo As STARTUPINFO)
    Private Declare Function SysReAllocString Lib "oleaut32.dll" (ByVal pBSTR As Long, Optional ByVal pszStrPtr As Long) As Long
    
    Private Sub Main()
        Dim sLnkFile As String, SUI As STARTUPINFO
    
        GetStartupInfoW SUI
    
        If SUI.dwFlags And STARTF_TITLEISLINKNAME Then
            SysReAllocString VarPtr(sLnkFile), SUI.lpTitle
            MsgBox "Launched via shortcut:" & vbCrLf & sLnkFile, vbInformation
        Else
            MsgBox "Launched directly", vbInformation
        End If
    End Sub
    Last edited by Victor Bravo VI; Nov 28th, 2018 at 09:06 AM. Reason: Added code

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,799

    Re: Was vb6 App launched from a shortcut or the ".exe"

    I have pretty much exactly the same situation with my users that you describe. However, I don't understand how knowing whether or not it's executed from a shortcut helps. For one, they can make a local copy and still be executing from a shortcut.

    Personally, I just have a version number that's prominently displayed on the main screen. I don't have a splash screen, but I do have something akin to a "main menu", and the version number and compile date are at the top of it. You are versioning, right? When I ask which version they're running, that takes care of everything for me. Through time, most of my users have become very aware of what and where that version number is.

    Name:  Version.png
Views: 86
Size:  1.7 KB

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    344

    Re: Was vb6 App launched from a shortcut or the ".exe"

    Quote Originally Posted by Obfuscated View Post
    which will always points to the most recent update.
    If you are using a database, or some other central data location, you can store the latest exe version in a field and then compare at startup.

    For us, we only allow the most recent version to connect to the database so it doesn't matter where they are running from. We attempt to auto update old exes to new ones and give on screen instructions if the update fails.

  7. #7
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    775

    Re: Was vb6 App launched from a shortcut or the ".exe"

    What I do is launch the program from the User's desktop for speed of execution. Then I compare to the file date on the server. If that date is newer, I then I prompt the User to update. If the User agrees, then I Shell out, copy the newer file from the server and restart the program. That way I only have to update the server.

    J.A. Coutts

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,799

    Re: Was vb6 App launched from a shortcut or the ".exe"

    Hmmm, my situation is both similar and different. Just as a preface, I also have a server database the program must attach to. If they're not running the executable from the server (in the same folder as the database), they must setup an INI file that tells the executable where the database is.

    Now, regarding updates, I suppose I'm in a trickier situation from what either DllHell or Couttsj outlined. Typically, I roll out updates a few times a year. Users can optionally pick those up if they like. Well over 99% of the time, when they grab an update, a few new fields will be added to the database. However, I try VERY hard to not change any of the previous fields, and to allow things to work if/when the new fields are Empty or Null. This allows a combination of old and new versions of the executable to use the database.

    On occasion however, there are changes that mandate an executable update from which they can not roll back. (Things that come to mind are index and/or relationship changes, or occasional database field clean-up that I'll do.) In these cases, I make it clear that there's no return (unless they backup both their old executable and the database, which they always do anyway.)

    And, separate from those non-roll-back situations, here's a situation I sometimes run into. I'll do a roll-out and then start getting calls that they don't like something. If it's not one of those non-roll-back situations, I'll tell them to just put the old executable back, and that I'll try to make some tweaks that address their concerns. (I know that opens up a whole other can of worms regarding my relationships with my users, but I'll ignore any comments about that.)

    So, how do I manage all of this? As said, I try very hard to add new fields (and sometimes tables too) without tampering with any of the existing fields and tables, and to allow Empty or Null fields to not disrupt anything. And in those non-roll-back situation, I don't use a Version Number to figure that out. Instead, I just examine the actual database tables, fields, indexes, and relationships to determine a "database" version (not executable version). So, if they try to use an old executable with a new (non-roll-back) version of the database, I just give them a warning, telling them that this executable isn't compatible with this version of the database.

    That approach has worked quite well for me for many years. Some may bristle at me using existing (or non-existing) fields as a version check, but it's deadly foolproof.

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  9. #9
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    344

    Re: Was vb6 App launched from a shortcut or the ".exe"

    Quote Originally Posted by Elroy View Post
    That approach has worked quite well for me for many years. Some may bristle at me using existing (or non-existing) fields as a version check, but it's deadly foolproof.
    It's a clever solution, but I also have another reason for forcing the same version: It makes support a lot easier and I never have to explain why Alice's copy does something different from Bob's computer. Everyone gets the same version.

  10. #10
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,799

    Re: Was vb6 App launched from a shortcut or the ".exe"

    Quote Originally Posted by DllHell View Post
    It makes support a lot easier and I never have to explain why Alice's copy does something different from Bob's computer. Everyone gets the same version.
    I truly wish I had that much control/power over my users. If you actually do, I envy you.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  11. #11
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    344

    Re: Was vb6 App launched from a shortcut or the ".exe"

    Quote Originally Posted by Elroy View Post
    I truly wish I had that much control/power over my users. If you actually do, I envy you.
    They rarely complain about this requirement.

    Besides, you have to do it sometimes anyways. Might as well slightly increase the frequency until it becomes the norm

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Oct 2015
    Posts
    17

    Resolved Re: Was vb6 App launched from a shortcut or the ".exe"

    Wrong reply button, Looks like I'll go with Victor Bravo VI ' s solution.

    To answer a couple questions...
    I do use version numbers when updating and I try to not make any more changes to databases/table than I have to.
    I also put out a notice, if it's only to a few people, that I have update a certain app.

    The main reason for doing this is so that I can put a small routine in the app that will see if it's launched from the exe. If it is, then I want to warn the user that they should be using a shortcut to insure that they have the latest update available. If they still want to copy/paste the app and use it, I can't do much about that. But at least I can notify them that they may not have the last update.

    Thanks for all the replies folks, greatly appreciated.
    Last edited by Obfuscated; Nov 28th, 2018 at 01:41 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width