Click here to Skip to main content
11,480,031 members (64,954 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6
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 11:12am
Comments
Sergey Alexandrovich Kryukov at 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

Rate this: bad
good
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:
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")
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 235
1 Sergey Alexandrovich Kryukov 215
2 Richard MacCutchan 100
3 F-ES Sitecore 85
4 DamithSL 65
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2015
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