Click here to Skip to main content
13,090,446 members (52,194 online)
Rate this:
Please Sign up or sign in to vote.
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 27-Feb-13 10:12am
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?..

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:

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")

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100