|
-
Jun 26th, 2003, 08:24 AM
#1
Thread Starter
Fanatic Member
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 :/
-
Jun 26th, 2003, 08:34 AM
#2
Fanatic Member
Have a look at this API in the MSDN.
Code:
AssocQueryString(ASSOCF_OPEN_BYEXENAME,
ASSOCSTR_EXECUTABLE,
pszExecutableName,
NULL,
pszPath,
pcchOut);
-
Jun 26th, 2003, 08:35 AM
#3
VB Code:
Shell "notepad.exe", vbNormalFocus
Shell "calc.exe", vbNormalFocus
Has someone helped you? Then you can Rate their helpful post. 
-
Jun 26th, 2003, 08:35 AM
#4
Frenzied Member
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:
Private Sub Command2_Click()
Shell "explorer.exe C:\temp\test.doc", vbNormalFocus
End Sub
OR use the Windows Shell to help you:
VB Code:
set wShell = CreateObject("Shell.Application")
wShell.Open "C:\temp\test.txt"
-
Jun 26th, 2003, 08:36 AM
#5
-
Jun 26th, 2003, 08:37 AM
#6
Addicted Member
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
-
Jun 26th, 2003, 08:43 AM
#7
Fanatic Member
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
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.
-
Jun 26th, 2003, 08:51 AM
#8
Thread Starter
Fanatic Member
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 :/
-
Jun 26th, 2003, 08:54 AM
#9
Fanatic Member
The functions SearchPath and AssocQueryString are for just that - searching your hard disk for a particular file.
-
Jun 26th, 2003, 09:02 AM
#10
Thread Starter
Fanatic Member
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 :/
-
Jun 26th, 2003, 09:23 AM
#11
Thread Starter
Fanatic Member
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 :/
-
Jun 26th, 2003, 09:46 AM
#12
Addicted Member
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?
-
Jun 26th, 2003, 10:29 AM
#13
you could use something like this:
VB Code:
Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal RootPath As String, ByVal InputPathName As String, ByVal OutputPathBuffer As String) As Long
Private Const MAX_PATH = 260
Private Sub Form_Load()
Dim tempStr As String, Ret As Long
tempStr = String(MAX_PATH, 0)
Ret = SearchTreeForFile("c:\", "vb5.exe", tempStr)
If Ret <> 0 Then MsgBox "VB5: " & Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
tempStr = String(MAX_PATH, 0)
Ret = SearchTreeForFile("c:\", "vb6.exe", tempStr)
If Ret <> 0 Then MsgBox "VB6: " & Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|