Installing a file in appdata
Installing a file in appdata
Installing a file in appdata
Installing a file in appdata
Installing a file in appdata
Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata
Installing a file in appdata Installing a file in appdata
Installing a file in appdata
Go Back  Xtreme Visual Basic Talk > > > Installing a file in appdata


Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2016, 11:16 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 59
Default Installing a file in appdata


Hi All,
I have a VB6 app which is supposed to copy a file from a shared drive to a folder in the users appdata.
The folders are enumerated as

Code:
Public Enum FolderEnum
    feApp = 0  ' \Program Files\Project (more reliable than App.Path)
    feCDBurnArea = 59 ' \Docs & Settings\User\Local Settings\Application Data\Microsoft\CD Burning
    feCommonAppData = 35 ' \Docs & Settings\All Users\Application Data
    feCommonDesktop = 25 ' \Docs & Settings\All Users\Desktop
    feCommonDocs = 46 ' \Docs & Settings\All Users\Documents
    feCommonPics = 54 ' \Docs & Settings\All Users\Documents\Pictures
    feCommonMusic = 53 ' \Docs & Settings\All Users\Documents\Music
    feCommonStartMenu = 22 ' \Docs & Settings\All Users\Start Menu
    feCommonStartMenuPrograms = 23 ' \Docs & Settings\All Users\Start Menu\Programs
    feProgramFiles = 38 ' \Program Files
    feProgramFilesCommon = 43 ' \Program Files\Common Files
    'feRecycleBin = 10 ' ???
    feUser = 40 ' \Docs & Settings\User
    feUserAppData = 26 ' \Docs & Settings\User\Application Data
    feUserCache = 32 ' \Docs & Settings\User\Local Settings\Temporary Internet Files
    feUserCookies = 33 ' \Docs & Settings\User\Cookies
    feUserDesktop = 16 ' \Docs & Settings\User\Desktop
    feuserdocs = 5 ' \Docs & Settings\User\My Documents
    feUserFavorites = 6 ' \Docs & Settings\User\Favorites
    feUserHistory = 34 ' \Docs & Settings\User\Local Settings\History
    feUserMusic = 13 ' \Docs & Settings\User\My Documents\My Music
    feUserPics = 39 ' \Docs & Settings\User\My Documents\My Pictures
    feUserRecent = 8 ' \Docs & Settings\User\Recent
    feUserSendTo = 9 ' \Docs & Settings\User\SendTo
    feUserStartMenu = 11 ' \Docs & Settings\User\Start Menu
    feUserStartMenuPrograms = 2 ' \Docs & Settings\User\Start Menu\Programs
    feUserStartup = 7 ' \Docs & Settings\User\Start Menu\Programs\Startup
    feWindows = 36 ' \WINNT
    feWindowsSystem = 37 ' C:\WINNT\System32
End Enum
Public Function SpecialFolder(pfe As FolderEnum) As String
    Const MAX_PATH = 260
    Dim strPath As String
    Dim strBuffer As String
    Dim lngHandle As Long
    Dim lngLen As Long
    
    strBuffer = Space$(MAX_PATH)
    If pfe = feApp Then
        lngHandle = GetModuleHandle(App.EXEName)
        lngLen = GetModuleFileName(lngHandle, strBuffer, MAX_PATH)
        strPath = Left$(strBuffer, lngLen)
        strPath = Left$(strPath, InStrRev(strPath, "\") - 1)
        If InStr(strPath, "Microsoft Visual Studio") > 0 Then strPath = App.Path
    Else
        If SHGetFolderPath(0, pfe, 0, 0, strBuffer) = 0 Then strPath = Left$(strBuffer, InStr(strBuffer, vbNullChar) - 1)
    End If
    If Right$(strPath, 1) = "\" Then strPath = Left$(strPath, Len(strPath) - 1)
    SpecialFolder = strPath
End Function
So determine the appdata folder I use
Code:
sAppData = SpecialFolder(feUserAppData)

This generally works but for one user it didn't. When I look at his appdata, there were multiple users.
The folders were
John
John.LT.THINK
John.COMPANYNAME

My code was adding to the "John" folder since that was his login, but the programs were using "John.COMPANYNAME"

Does anyone know who to choose the right user folder?

Many thanks in advance
Reply With Quote
  #2  
Old 01-15-2016, 07:09 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

The reason for the multiple folders is there user privileges, does the app need administration rights if so this might be the issue, in .net this happens quiet allot so the user gets asked a username and password of a higher account.
Reply With Quote
  #3  
Old 01-15-2016, 07:42 PM
dilettante's Avatar
dilettanteInstalling a file in appdata dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Shell32.dll has a type library that already defines special folder constants. No need for a ghetto-rigged Enum with funky names for known constants.

You are using ssfAPPDATA when you should probably be using ssfLOCALAPPDATA anyway, but that's a separate potential time bomb waiting to go off.

Then again perhaps it has blown up in your face, since those look like separate roaming profiles based on the logon context (local logon vs. domain logon).
Reply With Quote
Reply

Tags
docs, strpath, settingsall, appdata, folder, strbuffer, dim, files, settingsusermy, lnglen, program, settingsuserstart, settingsuserlocal, string, john, user, menu, left$strbuffer, left$strpath, menuprograms, usersstart, pfe, lnghandle, data, app.path


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Installing a file in appdata
Installing a file in appdata
Installing a file in appdata Installing a file in appdata
Installing a file in appdata
Installing a file in appdata
Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata Installing a file in appdata
Installing a file in appdata
Installing a file in appdata
 
Installing a file in appdata
Installing a file in appdata
 
-->