-
Nov 16th, 2012, 05:55 PM
#1
Thread Starter
Fanatic Member
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:
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?
-
Nov 16th, 2012, 06:12 PM
#2
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.
-
Nov 18th, 2012, 08:00 AM
#3
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.
-
Nov 18th, 2012, 10:26 PM
#4
Re: temp file location changed from XP to Vista/7
Originally Posted by Keithuk
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|