Results 1 to 4 of 4

Thread: temp file location changed from XP to Vista/7

  1. #1

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526

    temp file location changed from XP to Vista/7

    My program generates an html page to launch in the user's browser to make a printout of contacts. It worked fine in XP.

    Code:
        Open App.Path & "\print.htm" For Output As #1
    
            Print #1, strHTML(0);
            Print #1, strHTML(1)
    
        Close #1
    
        Call ShellExecute(0&, vbNullString, App.Path & "\print.htm", vbNullString, "C:\", 1)
    Like I said, the code works just fine bringing up a print page in the user's browser in XP, but check out the difference in where XP created the file and the new location for this file under Vista & 7:

    Name:  print-dilemma.jpg
Views: 172
Size:  30.0 KB

    The first line in the above image is working fine through app.path in XP, how do I code it so my print.htm file from this \VirtualStore\ folder will load just the same on Vista & 7?
    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: temp file location changed from XP to Vista/7

    This is an issue because your program breaks the rules that say programs should not write to files under Program Files (which is redirected to Program Files (x86) for 32-bit programs on 64-bit Windows).

    What you really need to do is fix the program. It should use a folder under the [LocalAppData] special folder, usually named as Company\Application. This works on any version of Windows from Win95 with thr IE4 Desktop Update through Windows 8.

    The special folders are easy to locate using the Shell object. Example:

    Code:
    Const ssfLOCALAPPDATA = &H1C&
    Dim LAD As String
    
    LAD = CreateObject("Shell.Application").NameSpace(ssfLOCALAPPDATA).Self.Path
    The special folder constants can be found in your MSDN CDs, or at ShellSpecialFolderConstants Enumeration.

    You can also set a reference to Microsoft Shell Controls and Automation, which offers early binding and predefines the special folder enumeration for you.

  3. #3
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,238

    Re: temp file location changed from XP to Vista/7

    If your using App.Path & "\print.htm" then the file will be saved where the exe is running from. Thats providing you have admin rights to save that file in that location otherwise you will get a 75 error, check for this error number when you save.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: temp file location changed from XP to Vista/7

    Quote Originally Posted by Keithuk View Post
    If your using App.Path & "\print.htm" then the file will be saved where the exe is running from. Thats providing you have admin rights to save that file in that location otherwise you will get a 75 error, check for this error number when you save.
    You'll only see the security violation error if you program has a manifest marking it as Vista aware. If running in legacy appcompat mode the file will be virtualized.

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