Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Is there a simple way to tell what drive was used to load a program in VB?

My problem is I wrote a program, once installed it needs to check the
drive it was installed FROM. That way I can use that data later on in that program.

Something like E:\install and capture that drive letter for use in the program.
At this point I want the program to run and add information so its being written
to run on a flash drive.

Any suggestion would be a great help...
Posted
Comments
Sergey Alexandrovich Kryukov 27-Feb-13 16:21pm    
Why? By your application? this is not a problem at all, isn't it obvious? System-wide? Well, possible, but... OK, you are using VB6! I would suggest to forget it. Any specific reason for VB6? Just to waste your life for nothing?..
—SA

1 solution

It has been more than a decade since I last used VB6. Unfortunately, I don't have a copy that I can use to test my solution.

I believe that the following will retrieve the path to the executing program:
App.Path

From this string, you should be able to extract either the drive letter or the UNC path (if the program is run from a file server).

I found the following on the MSDN web site[^]. It shows how App.Path is used to get the path of the executing program.

The following example demonstrates how to display an image file that is stored in the application's folder by retrieving the path to the executing application.

' Visual Basic 6.0
Picture1.Picture = LoadPicture(App.Path & "\Logo.jpg")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900