Randem
I have just downloaded and installed your latest Beta version.
Given that it has no code function like
[Code]
function GetAppFolder(Param: String): String;
begin
if InstallOnThisVersion('0,6', '0,0') = irInstall then
Result := 'C:UsersPublic' ExpandConstant('{username}')
else
Result := ExpandConstant('{pf}');
end;
Then is it the case that I should use this new version only for Vista and the old version for XP and below ???????
Or can only one install routine be used for all versions of windows just like it could before this latest beta update ?????
If you include the Vista template file that code would surface.
The one install routine can be used only if your app is Vista Compliant otherwise you need to use the legacy install (with the code).
If I use the Vista template file then the code is automatically entered into my script.
Which is fine
But then if I change my VB code to use the appdata directory then if my app were running on an XP machine then the database would not be found?
Can you remember the VB6 code that would check if the appdata directory existed ?
Else I would have to code it on a connection failure/error it is never the best way to do it, but it would be the best I could do without help.
However if you are not sure about the code I will post on the VB web-site both you and I use for a solution.
(Message edited by JohnMax on December 05, 2007)
Using the beta version you can select if you want the data installed in the {app} or the {userappdata} paths. If you check mark the file or folder it will be installed in the {userappdata} folder if unchecked in the {app} folder. Of course your code has to use the APPDATA path to locate the data if using the {userappdata} method.
The code would be myDataPath = Environ(APPDATA)
In Inno Setup the folder would be automatically created upon install.
Yes I understand that, but inno would also install the database in a folder Program Filesappdata directory if the install was made on an XP machine would it not??
What I am asking is how to code my app so that the database would be found on both XP and Vista, so I only need one install routine
No, the script would not change. It would install it in the APPDATA path on XP also.
Open up a command prompt then key in
Set APPDATA
you will see where the data would go. You just need to create a folder in that folder for your app. If you get the appdata path in your code and pre-pend it to your filename of the file you want to open, you app would have no choice but to attempt to get the file from that location. Use it the same way you would use App.Path in your code.
Usual way
Filename = App.Path & \mydatabase.mdb
Now you would use
Filename = Environ(APPDATA) & \myappname\mydatabase.mdb
This would be good for XP and Vista.
So if your data was references as in my prior post your script would reference that location as:
DestDir: {userappdata\myappname}
My appdata path is APPDATA=C:Documents and SettingsJohnMaxApplication Data
However the application is installed at C:Program FilesMy App on an XP or lower machine and on a Vista machine it would be C:UsersPublicMy App
So I just cannot see how this will work?
As on Vista inno would install my database at C:UsersPublicMyAppappdata would it not?
No, You data has nothing to do with the install location as APPDATA shows. No matter where the app is installed the data will still be installed in the APPDATA folder location and that is where you reference it from in your app.
Inno Setup would install your database anywhere you tell it. If you check the box on the database it will get installed to the APPDATA folder if it is not checked the the {app} folder wherever you chose for that to go. One has nothing to do with the other.
My recommendation is that in your installation folder you have a folder named database where you keep your default database. When you add it in InnoScript in the add folder tab and run InnoScript you will see a folder for the DestDir for that folder in the
DestDir: {userappdata}YourCompanyNameYourAppNameDatabase
That is where the database will be installed. {userappdata} will equal APPDATA on the target machine.
YourCompanyName will only show up in the script if your VBP file has the CompanyName parameter filled in.
randem
This is what I am talking about:
**************************************************
Private Sub Form_Load()
On Error GoTo Form_Load_Error
Set AK = New ADODB.Connection
AK.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & _
App.Path & jet1.mdb;Jet OLEDB:Database Password=Open;
AK.Open
On Error GoTo 0
Exit Sub
Form_Load_Error:
MsgBox Error & Err.Number & ( & Err.Description & _
) in procedure Form_Load of Form Form1
Set AK = New ADODB.Connection
AK.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & _
APPDATA & jet1.mdb;Jet OLEDB:Database Password=Open;
AK.Open
End Sub
************************************************
Now I believe the code above would work on both XP and Vista but it's not the best way to check which location the data files have been installed by using an error in the connection as it may be caused by another problem.
All I am asking is do you know some better code or will I post elsewhere for a sol}ution?
(Message edited by JohnMax on December 05, 2007)
(Message edited by JohnMax on December 05, 2007)
No that code will not work on either unless you had somewhere in your code:
APPDATA = Environ(APPDATA)
XP, Vista who cares they both have APPDATA that points to different locations so if they were installed using the {userappdata} (APPDATA) environmental variable then you can access them using the same variable...
Think of it this way. When you use App.Path do you care where the user installed the program? No, that is why you use App.Path to get the location. The same goes for APPDATA.
As far as better code you can't do much better... What ever you use in your code you use in the script... No difference...
This would be supreme and the best you need.
APPDATA = Environ(APPDATA) & yourcompanynameyourappname
Set AK = New ADODB.Connection
AK.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=APPDATA & jet1.mdb;Jet OLEDB:Database Password=Open;
AK.Open
Or this. But you have to be consistent in your app and your installation script.
APPDATA = Environ(APPDATA) & yourappname
Set AK = New ADODB.Connection
AK.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=APPDATA & jet1.mdb;Jet OLEDB:Database Password=Open;
AK.Open
If you use the first example then in your scripts you need
DestDir: {userappdata}yourcompanynameyourappname
or the second example
DestDir: {userappdata}yourappname",
Also remember to open any data files that you are just reading from the {app} folder with Access Read Shared. Do not open any files in the {app} folder with write access or they will fail and require administrator access to run, which is precisely what you really do not want. This will help your app to become Vista Compliant.