Results 1 to 13 of 13

Thread: Finding application paths..

  1. #1

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641

    Unhappy Finding application paths..

    Hi All,

    I am making a simple program launcher, and I am having some problems.

    So far, I have been able to find the Microsoft Office paths, but not these other ones. If anyone knows how I would go about getting the full path name, that would be very much appreciated.

    The paths of programs I'm looking for are:
    MSN Messenger
    Microsoft Paint;Notepad;Calculator;Command Prompt
    Windows Media Player
    Visual Basic

    Thanks in advance,
    /: Tim :\____________________
    \: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/

  2. #2
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574
    Have a look at this API in the MSDN.

    Code:
    AssocQueryString(ASSOCF_OPEN_BYEXENAME,
                     ASSOCSTR_EXECUTABLE,
                     pszExecutableName,
                     NULL,
                     pszPath,
                     pcchOut);

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    VB Code:
    1. Shell "notepad.exe", vbNormalFocus
    2. Shell "calc.exe", vbNormalFocus


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    The paths will differ depending on how the applications have been installed.
    You will need to go to the Registry to find the actual path.

    You will / may find it better to use a different way of launching the application.
    For example: On the START, RUN button you can type NOTEPAD and it laucnhes notepad, but you can't type PAINT.

    Take a look at the ShellExecute API function (search in this forum) as this launches the application without needing to know its path.

    OR use Explorer to help you:
    VB Code:
    1. Private Sub Command2_Click()
    2.     Shell "explorer.exe C:\temp\test.doc", vbNormalFocus
    3. End Sub
    OR use the Windows Shell to help you:
    VB Code:
    1. set wShell = CreateObject("Shell.Application")
    2. wShell.Open "C:\temp\test.txt"

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    VB Code:
    1. Shell "cmd.exe", vbNormalFocus


    Has someone helped you? Then you can Rate their helpful post.

  6. #6
    Addicted Member big_k105's Avatar
    Join Date
    May 2003
    Location
    North Dakota
    Posts
    195
    Microsoft Paint;Notepad;Calculator;Command Prompt these all seem to be in your system32 folder C:\WINNT\system32 in win2k.

    "C:\Program Files\DevStudio\VB\VB5.EXE" for vb5 bet its the same for vb6 or .net

    dont know about msn messenger cause i dont have it on this computer

    this mite be it for media player but this is an older media player
    C:\Program Files\Windows Media Player\mplayer2.exe

  7. #7
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574
    Just to add another word. The AssocQueryString API I told you about in the previous post above, queries the ASSOC command on NT based systems. There is a command you can run at the command prompt called ASSOC to retrieve file extention associations. For instance you say

    Code:
    ASSOC .doc
    on the command prompt and NT will tell you back "Microsoft Word Document".

    This API AssocQueryString will run only on NT based platforms. And it will find you any path to any executable file by calling ASSOC which in turn looks in the HKEY_CLASSES_ROOT hive of the registry.

    However, if you are on Win9x, you could use another API called SearchPath. This will work on both NT based systems as well as Win 9x systems. The drawback with this API is that it requires you to specify a folder/path to search in where it will start searching. You can always specify the root (C:\) and it will search the whole of your C: but what if you have your disk partitioned logically and you want to search just anywhere on the whole of the physical disk including all drives. Then you will have to call this function for every drive until it finds the file. Not a very serious drawback though.

  8. #8

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641
    OK,

    I have the MSN and Windows Media Player ones done, I used the registry for that.

    I can't find a registry key for visual basic..

    Now, apparently the paint notepad and whatever are all in the system directory.

    Can I do a search across the system for these files somehow??

    I seem to remember notepad being in C:\Windows on Win98, and in C:\Windows\System32\ on XP.

    this program has to be able to function from 98 to XP

    thanks in advance,
    /: Tim :\____________________
    \: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/

  9. #9
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574
    The functions SearchPath and AssocQueryString are for just that - searching your hard disk for a particular file.

  10. #10

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641
    OK, everything down except for finding VB..

    thanks for those functions! they work very well!!

    What would VB be called??
    In mine ive got E:\Program Files\Microsoft Visual Studio\vb98\vb6.exe

    how would I find that file, if they have vb5 for example?
    /: Tim :\____________________
    \: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/

  11. #11

    Thread Starter
    Fanatic Member tim_l_012's Avatar
    Join Date
    Mar 2001
    Location
    Next to a Coffee Cup.
    Posts
    641
    oh no!

    I forgot internet explorer..

    is that always located at C:\Program Files\Internet Explorer\iexplore.exe?

    thanks in advance,
    /: Tim :\____________________
    \: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/

  12. #12
    Addicted Member big_k105's Avatar
    Join Date
    May 2003
    Location
    North Dakota
    Posts
    195
    ok i have a question are you wanting use to help tell you the path or help showing you how to write a program that will find them for you?

  13. #13
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    you could use something like this:
    VB Code:
    1. Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal RootPath As String, ByVal InputPathName As String, ByVal OutputPathBuffer As String) As Long
    2. Private Const MAX_PATH = 260
    3. Private Sub Form_Load()
    4.     Dim tempStr As String, Ret As Long
    5.     tempStr = String(MAX_PATH, 0)
    6.     Ret = SearchTreeForFile("c:\", "vb5.exe", tempStr)
    7.     If Ret <> 0 Then MsgBox "VB5: " & Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
    8.     tempStr = String(MAX_PATH, 0)
    9.     Ret = SearchTreeForFile("c:\", "vb6.exe", tempStr)
    10.     If Ret <> 0 Then MsgBox "VB6: " & Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
    11. End Sub

    only problem is..if they installed it to say..the D drive..or E ...or etc...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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