|
-
Feb 24th, 2008, 02:01 PM
#17
Thread Starter
PowerPoster
Re: Edit PDW for Vista
 Originally Posted by si_the_geek
That is correct. Using my previous example, you would create the folder: strAppData & "MyApp" (or strAppData & "\MyApp").
If you sell multiple programs, you may even want to make a "MyCompany" folder, and put the "MyApp" folder inside it (but this may cause problems for users who upgrade from previous versions of your program).
I have been doing some testing with code i got,i think from here om my xp machine:
This does not work:
HTML Code:
Option Explicit
'SHGetFolderPath API: locates special windows folders
Private Declare Function SHGetFolderPath Lib "shfolder.dll" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, _
ByVal nFolder As Long, ByVal hToken As Long, ByVal dwFlags As Long, ByVal pszPath As String) As Long
Private Const CSIDL_FLAG_MASK = &HFF00
Private Const SHGFP_Type_CURRENT = &H0
Private Const MAX_PATH = 260 'max path length
'some usual constants. There are a lot more, just google a bit and you'll find them.
Private Const CSIDL_APPDATA As Long = &H1A 'the {current user}\Application Data folder
Private Const CSIDL_COMMON_APPDATA As Long = &H23 'the {all users}\Application Data folder. Use this if all users will access the same data.
Private Const CSIDL_COMMON_DOCUMENTS As Long = &H2E 'the {all users}\Documents folder (shared documents)
'this returns the path for the selected special folder
Function GetSpecialPath(CSIDL As Long) As String
Dim strPath As String
Dim iReturn As Long
strPath = String(MAX_PATH, 0)
iReturn = SHGetFolderPath(0, CSIDL, 0, SHGFP_Type_CURRENT, strPath)
GetSpecialPath = Left$(strPath, InStr(1, strPath, Chr(0)) - 1)
End Function
'now, an app.path replacement to save you some coding.
Public Function NewPath() As String
Dim strTemp As String
strTemp = Trim(GetSpecialPath(CSIDL_COMMON_APPDATA)) 'replace the constant with the one you need
'now, since app.path doesn't end with a "\", we'll strip it out just to keep the rest of your code unchanged
If Right$(strTemp, 1) = "\" Then strTemp = Left$(strTemp, Len(strTemp) - 1)
NewPath = strTemp
End Function
I'm calling it like this:
myfile = NewPath & "\myApp\quicker.dat"
it does not add the myapp folder
but this will add the qucker.dat
myfile = NewPath & "\quicker.dat", but not in a folder
do you know why ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
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
|