Results 1 to 6 of 6

Thread: Vista & Creating a File in "Program Files"

  1. #1

    Thread Starter
    Lively Member feneck's Avatar
    Join Date
    Mar 2007
    Location
    Australia, Queensland, Gympie
    Posts
    85

    Exclamation Vista & Creating a File in "Program Files"

    Hello everyone. I have recently been developing a program, and just the other day I completed it. I developed this program on Windows Vista Home Basic. When I ran the program it worked perfect. I compiled my program and made it an installer. When my program runs inside the "Program Files" folder, it returns this error: "Run-Time error '75': Path/File Error".

    This is due to my program creating a "settings.txt" on the app startup. How do i fix this?

    thankyou

    REMEMBER TO RATE

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Vista & Creating a File in "Program Files"

    The basic rule seems to be that only a recognized installer or elevated process can write to "Program Files."

    The recommended workaround is to relocate settings files, data files, etc. into "Common Files" located via Microsoft Shell Controls and Automation (Shell32.dll) which is an ActiveX DLL or else ShFolder.dll which is a standard DLL. You should use these "lookups" because the folders are in different paths for different machines and OSs.

    Per-user settings should be in a separate file located under "Application Data" and this should also be requested of the OS in the same manner.

    For "Common Files" ask for ssfCOMMONDATA (or CSIDL_COMMON_APPDATA).

    For "Application Data" ask for ssfAPPDATA (or CSIDL_APPDATA).

    Note: there is also a "Local Settings\Application Data" folder CSIDL_LOCAL_APPDATA for settings that stick to one machine in the event roaming profiles are used for users.


    To properly use these filesystem locations you are supposed to create a subdirectory for your "company name" and under that another for your "application name." Then put your settings or data under that.

    Note that any working "document" files that are meant to be found and manipulated by the user (i.e. via Explorer) should be placed into CSIDL_PERSONAL ("My Documents") or CSIDL_COMMON_DOCUMENTS ("All Users\Documents").

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Vista & Creating a File in "Program Files"

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Vista & Creating a File in "Program Files"

    Using the CSIDL locators works on XP as well, so you don't need to fiddle around.

    You should also refrain from hard-coded assumptions about the known folder paths. For example, on Windows XP Professional 64-bit Edition and Windows Vista x64, the program files path is C:\Program Files (x86) for 32-bit programs and C:\Program Files for 64-bit programs. These known paths are changed from Windows XP, and users can reconfigure the location of many of these folders and even locate them on different drives. So, always use the CSIDL constants to avoid confusion and potential problems. Windows Setup understands these known folder locations and will move the data when upgrading the operating system from Windows XP; in contrast, use of non-standard locations or hard-coded paths may well fail after an OS upgrade.
    File Access as a Standard User

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Vista & Creating a File in "Program Files"

    These are my sources for interacting with Vista's new security technologies. They should be very helpful.

    http://msdn.microsoft.com/msdnmag/is...C/default.aspx
    http://technet2.microsoft.com/Window....mspx?mfr=true
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Hyperactive Member Hassan Basri's Avatar
    Join Date
    Sep 2006
    Posts
    324

    Re: Vista & Creating a File in "Program Files"

    Thanks RobDog888 and dilettante, I have added your links and information to the post:

    Modifications Required for VB6 Applications to Work on Vista

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width