looking / storing working directory

looking / storing working directory

Post by Dave Kou » Tue, 04 Aug 1998 04:00:00



How do you setup VB to look for a working directory ?  The app may be in one
drive/directory and the data may be in another location. When my application
starts I would like it to point to the correct data location. Is it best to
store that information in a ini file ? Any samples available on the web ?

Thanks in advance.

--
David L. Koup
General Manager
Koup's Cycle Shop Inc.
"The Good Times Store"
http://www.koups.com
"Kawasaki" "Suzuki" "Ducati" "Moto Guzzi"
Established 1957
"Dealer News Magazine Top 100 Dealer"

 
 
 

looking / storing working directory

Post by Paul Gooc » Wed, 05 Aug 1998 04:00:00


Hi, Dave.

You could store it in an .ini, .txt or .dat file, probably several others.
Even a file without an extension. Give the user the choice to set where the
data is to be saved by using the "browse for folder" common dialogue. Store
the returned path in a file. Here's some code :

Paste this into your form, using a command button called cmdChange to call
the Browse Dialogue. Add a textbox to your form, called txtDataLocation, to
display to the user where his data is going. You can of course change the
names of the command button, textbox and the settings.ini to anything you
want.

'***********Begin Paste***********

Private Sub cmdChange_Click()
Dim bi As BROWSEINFO
Dim FileNum
Dim nFolder As Long
Dim IDL As ITEMIDLIST
Dim pIdl As Long
With bi
nFolder = 17

If SHGetSpecialFolderLocation(ByVal Me.hWnd, ByVal nFolder, IDL) = NOERROR
Then
 .pidlRoot = IDL.mkid.cb
 End If

 .lpszTitle = "Enter some text here to explain this function."

.ulFlags = BIF_RETURNONLYFSDIRS

End With

pIdl = SHBrowseForFolder(bi)
If pIdl = 0 Then
   Exit Sub
   End If

sPath = String$(MAX_PATH, 0)
SHGetPathFromIDList ByVal pIdl, ByVal sPath

' This is the location that was selected

txtDataLocation = sPath

CoTaskMemFree pIdl

'This part write the location selected to a file
'called setings.ini which needs to be in the
'same location as your App

FileNum = FreeFile
   Open "settings.ini" For Output As FileNum
   Write #FileNum, txtDataLocation.Text
   Close FileNum

End Sub

'**************End Paste********

Add a new module and paste the following in :

'**********Begin Paste*************

Option Explicit
Type SHITEMID
    cb As Long
    abID() As Byte
End Type
Type ITEMIDLIST
    mkid As SHITEMID
End Type
Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias
"SHGetPathFromIDListA" _
                              (ByVal pIdl As Long, ByVal pszPath As String)
As Long
Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
                              (ByVal hwndOwner As Long, ByVal nFolder As
Long, _
                              pIdl As ITEMIDLIST) As Long
Public Const NOERROR = 0
Public Const CSIDL_DESKTOP = &H0
Public Const CSIDL_PROGRAMS = &H2
Public Const CSIDL_CONTROLS = &H3
Public Const CSIDL_PRINTERS = &H4
Public Const CSIDL_PERSONAL = &H5
Public Const CSIDL_FAVORITES = &H6
Public Const CSIDL_STARTUP = &H7
Public Const CSIDL_RECENT = &H8
Public Const CSIDL_SENDTO = &H9
Public Const CSIDL_BITBUCKET = &HA
Public Const CSIDL_STARTMENU = &HB
Public Const CSIDL_DESKTOPDIRECTORY = &H10
Public Const CSIDL_DRIVES = &H11
Public Const CSIDL_NETWORK = &H12
Public Const CSIDL_NETHOOD = &H13
Public Const CSIDL_FONTS = &H14
Public Const CSIDL_TEMPLATES = &H15
Public Const MAX_BROWSEPATH = 260
Public sPath As String

Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)
Declare Function SHBrowseForFolder Lib "shell32.dll" Alias
"SHBrowseForFolderA" _
                              (lpBrowseInfo As BROWSEINFO) As Long

Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Public Const BIF_RETURNONLYFSDIRS = &H1
Public Const BIF_DONTGOBELOWDOMAIN = &H2
Public Const BIF_STATUSTEXT = &H4
Public Const BIF_RETURNFSANCESTORS = &H8
Public Const BIF_BROWSEFORCOMPUTER = &H1000
Public Const BIF_BROWSEFORPRINTER = &H2000

'*********End Paste*********
--

Regards, Paul.

IE4 Assistant Forum Manager




>How do you setup VB to look for a working directory ?  The app may be in
one
>drive/directory and the data may be in another location. When my
application
>starts I would like it to point to the correct data location. Is it best to
>store that information in a ini file ? Any samples available on the web ?

>Thanks in advance.

>--
>David L. Koup
>General Manager
>Koup's Cycle Shop Inc.
>"The Good Times Store"
>http://www.koups.com
>"Kawasaki" "Suzuki" "Ducati" "Moto Guzzi"
>Established 1957
>"Dealer News Magazine Top 100 Dealer"


 
 
 

looking / storing working directory

Post by Matt Lebea » Wed, 05 Aug 1998 04:00:00


Dave...

I prefer to store working directory paths in the registry:

    SaveSetting "MyProgram", "Paths", "Reports", "C:\DATA\REPORTS\"
    SaveSetting "MyProgram", "Paths", "Images", "C:\DATA\IMAGES\"
    SaveSetting "MyProgram", "Options", "AllowDelete", True

Retrieval is just as easy:

    NewPath = GetSetting("MyProgram","Paths","Reports","C:\")

(The last parameter is the default value to use in case one is not found in the
registry)
Hope this helps-
                                                Matt Lebeau, Research Genetics


> How do you setup VB to look for a working directory ?  The app may be in one
> drive/directory and the data may be in another location. When my application
> starts I would like it to point to the correct data location. Is it best to
> store that information in a ini file ? Any samples available on the web ?

> Thanks in advance.

> --
> David L. Koup
> General Manager
> Koup's Cycle Shop Inc.
> "The Good Times Store"
> http://www.koups.com
> "Kawasaki" "Suzuki" "Ducati" "Moto Guzzi"
> Established 1957
> "Dealer News Magazine Top 100 Dealer"

 
 
 

1. Set current directory as working directory

This is a multi-part message in MIME format.
--------------28AA53F18E992791EBBCFC76
Content-Type: text/plain; charset=us-ascii
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit

I just upgraded to Paradox 8 and I am having some difficulties in
changing the current directory to the working directory.  When I press
the icon to make the change, it freezes and I end up having to end the
task and reboot.  I have noticed that it occurs more often when setting
a network drive as the working directory as opposed to a local drive,
but since I am able to set the network drive as the working directory (1

out of 10 times) I have ruled out a configuration error.  I have tried
reinstalling paradox and still no success.  Does anyone have any
suggestions?  It is really getting quite annoying.

My computer is running on Windows95.

--------------28AA53F18E992791EBBCFC76
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Jefferson England
Content-Disposition: attachment; filename="vcard.vcf"

begin:vcard
fn:Jefferson England
n:England;Jefferson

x-mozilla-cpt:;0
x-mozilla-html:FALSE
end:vcard

--------------28AA53F18E992791EBBCFC76--

2. @@ERROR not getting set

3. Looking for FoxBASE 3rd party products directory

4. Databases and BP 7.0

5. Oracle Internet Directory : looking for information on OID's relational storage model

6. Evaluating VPPRO

7. Help, cannot get name of current working directory???

8. Merge Replication on VPN

9. Working directory question

10. How to work with the Virtual Directory from visual Interdev

11. replication working directory

12. working directory when using ed in sqlplus

13. Alias & Working directory problem