Thread View: borland.public.cppbuilder.nativeapi
17 messages
17 total messages
Started by bar
Wed, 16 Apr 2008 18:18
Delete File
Author: bar
Date: Wed, 16 Apr 2008 18:18
Date: Wed, 16 Apr 2008 18:18
9 lines
1036 bytes
1036 bytes
Hi
DeleteFile("C:\\Program Files\\MyProgram\\a.jpg");
The above works in XP. In Vista it doesn't work, the user is administrator.
How to resolve the issue.
Thanks
SA
Re: Delete File
Author: Remy Lebeau (TeamB)
Date: Wed, 16 Apr 2008 20:30
Date: Wed, 16 Apr 2008 20:30
14 lines
1349 bytes
1349 bytes
"bar" <shaikakbar250281@yahoo.co.in> wrote in message
news:480642de@newsgroups.borland.com...
> DeleteFile("C:\\Program Files\\MyProgram\\a.jpg");
>
> The above works in XP. In Vista it doesn't work, the
> user is administrator. How to resolve the issue.
Did you verify that the file actually exists? What does DeleteFile()
actually return? If FALSE, what does GetLastError() return?
Gambit
Re: Delete File
Author: Bob Gonder
Date: Thu, 17 Apr 2008 03:56
Date: Thu, 17 Apr 2008 03:56
11 lines
1279 bytes
1279 bytes
bar wrote:
>DeleteFile("C:\\Program Files\\MyProgram\\a.jpg");
>
>The above works in XP. In Vista it doesn't work, the user is administrator.
>How to resolve the issue.
Fairly simple, really...
Don't place any files in the Program Files that you want to delete.
Only viruses and malware try to delete files in there.
Re: Delete File
Author: Alan Bellingham
Date: Thu, 17 Apr 2008 07:54
Date: Thu, 17 Apr 2008 07:54
22 lines
1545 bytes
1545 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote:
>bar wrote:
>
>>DeleteFile("C:\\Program Files\\MyProgram\\a.jpg");
>>
>>The above works in XP. In Vista it doesn't work, the user is administrator.
>>How to resolve the issue.
>
>Fairly simple, really...
>Don't place any files in the Program Files that you want to delete.
>
>Only viruses and malware try to delete files in there.
... and any program using the old, old paradigm of keeping everything in
one place.
Alan Bellingham
--
Team Browns
<url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions
<url:http://www.borland.com/newsgroups/netiquette.html> netiquette
Re: Delete File
Author: Bob Gonder
Date: Thu, 17 Apr 2008 17:37
Date: Thu, 17 Apr 2008 17:37
9 lines
1309 bytes
1309 bytes
Alan Bellingham wrote: >Bob Gonder wrote: > >>Only viruses and malware try to delete files in there. > >... and any program using the old, old paradigm of keeping everything in >one place. By the great and glorious wisdom of Microsoft, they are the same thing.
Re: Delete File
Author: Ted Lyngmo
Date: Thu, 17 Apr 2008 20:14
Date: Thu, 17 Apr 2008 20:14
35 lines
2350 bytes
2350 bytes
Bob Gonder wrote:
> bar wrote:
> >
> > DeleteFile("C:\\Program Files\\MyProgram\\a.jpg");
> >
> > The above works in XP. In Vista it doesn't work
>
> Fairly simple, really...
> Don't place any files in the Program Files that you want to delete.
>
> Only viruses and malware try to delete files in there.
Yikes... One of my apps (totally free, but not viral or malicious in any
way) uses the installation directory (C:\Program...) and its contents as
a point of reference. The individual users gets their default files from
there. On occasion, the default files names changes and some files are
removed and some are added and some files even gets their contents
changed... If *any* user of the app decides to click the "update" button
(when presented to them), everything in the reference directory
(C:\Program...) will get updated.
Updating has exactly the same effect as installing the app. clean,
except it wont be noticed by old users of the app.
"First time user? Fine, you get the latest default settings! Old user?
Ok, just enjoy the new features of the application. Your old settings
are unchanged! Really!"
How should I split my application up to pass the viral test?
Is there some sort of posix placement for apps./files in Windows
nowadays? That'd be great!
Cheers,
Ted
Re: Delete File
Author: Remy Lebeau (TeamB)
Date: Thu, 17 Apr 2008 21:03
Date: Thu, 17 Apr 2008 21:03
22 lines
1726 bytes
1726 bytes
"Ted Lyngmo" <tedREMOVETHIS@lyncon.se> wrote in message news:4807af87$1@newsgroups.borland.com... > One of my apps (totally free, but not viral or malicious in any way) > uses the installation directory (C:\Program...) and its contents as a > point of reference. The individual users gets their default files from > there. That portion is fine. > On occasion, the default files names changes and some files are > removed and some are added and some files even gets their > contents changed... If *any* user of the app decides to click the > "update" button (when presented to them), everything in the > reference directory (C:\Program...) will get updated. Your updater needs to run under an admin account in order to changed files in the "C:\Program Files" hierarchy. Gambit
Re: Delete File
Author: Ted Lyngmo
Date: Thu, 17 Apr 2008 21:41
Date: Thu, 17 Apr 2008 21:41
19 lines
1765 bytes
1765 bytes
Remy Lebeau (TeamB) wrote: > Ted Lyngmo wrote: > > > > On occasion, the default files names changes and some files are > > removed and some are added and some files even gets their > > contents changed... If *any* user of the app decides to click the > > "update" button (when presented to them), everything in the > > reference directory (C:\Program...) will get updated. > > Your updater needs to run under an admin account in order to changed > files in the "C:\Program Files" hierarchy. Howdy Remy! Got that, but if we (the users and I) needs the program to update the way it did pre Vista? It's been working since W95... Cheers, Ted
Re: Delete File
Author: Remy Lebeau (TeamB)
Date: Thu, 17 Apr 2008 22:51
Date: Thu, 17 Apr 2008 22:51
13 lines
1481 bytes
1481 bytes
"Ted Lyngmo" <tedREMOVETHIS@lyncon.se> wrote in message news:4807c404$1@newsgroups.borland.com... > Got that, but if we (the users and I) needs the program to > update the way it did pre Vista? It's been working since W95... These restrictions are not new in Vista. They have been around for a long time. It is just that each new OS version enforces them more then the previous OS version did. Gambit
Re: Delete File
Author: Bob Gonder
Date: Fri, 18 Apr 2008 03:04
Date: Fri, 18 Apr 2008 03:04
16 lines
1504 bytes
1504 bytes
Ted Lyngmo wrote: >Is there some sort of posix placement for apps./files in Windows >nowadays? That'd be great! Currently (Vista), C:Users/[UserName]/AppData/[Local or Roaming]/YourApp If you use old code, Vista places your data in c:ProgramData/, same folder structure as Program Files. I have no idea how many version of Windows that will last. You should be (for several releases of Windows now) using the shell functions to get the data paths. Such as SHGetFolderLocation and a few more SHGet.... You should be able to Google this group for code.
Re: Delete File
Author: Ted Lyngmo
Date: Fri, 18 Apr 2008 05:47
Date: Fri, 18 Apr 2008 05:47
32 lines
1863 bytes
1863 bytes
Bob & Remy, I'm sure you are right... Most of the code used when installing and updating my app is derived from what I've seen in the registry ... in W95 & W98 :-) Time to read up a bit... Thanks, Ted Bob Gonder wrote: > Ted Lyngmo wrote: > > >>Is there some sort of posix placement for apps./files in Windows >>nowadays? That'd be great! > > > Currently (Vista), C:Users/[UserName]/AppData/[Local or Roaming]/YourApp > > If you use old code, Vista places your data in c:ProgramData/, > same folder structure as Program Files. > I have no idea how many version of Windows that will last. > > You should be (for several releases of Windows now) using > the shell functions to get the data paths. > Such as SHGetFolderLocation and a few more SHGet.... > > You should be able to Google this group for code. >
Re: Delete File
Author: bar
Date: Fri, 18 Apr 2008 07:40
Date: Fri, 18 Apr 2008 07:40
21 lines
1714 bytes
1714 bytes
Onething i noticed a "Virtual Store\Program Files\App\" directory storing exact backup of directories that have been created in the "C:\Program Files\App\" directory. My app when runs checks for the directory and create some directories in the "C:\Program Files\App\" if not exist. XP it was working fine. In vista if i delete the sub directories under "C:\Program Files\App\" manually. The program is considering the "Virtual Store\Program Files\App\" path as a app folder path and i don't have any control over the "C:\Program Files\App\" directory to create sub directories. But anyhow i changed the app subdirectories path for the below. XP -C:\Documents and Settings\All Users\Application Data\App\SubDirectory Vista - C:\Program Data\App\SubDirectory. Is this recommended. I need my app sub directories for all users, instead of creating for each user. Thanks for comments SA
Re: Delete File
Author: Remy Lebeau (TeamB)
Date: Fri, 18 Apr 2008 08:09
Date: Fri, 18 Apr 2008 08:09
45 lines
2597 bytes
2597 bytes
"bar" <shaikakbar250281@yahoo.co.in> wrote in message
news:48085050@newsgroups.borland.com...
> Onething i noticed a "Virtual Store\Program Files\App\" directory
> storing exact backup of directories that have been created in the
> "C:\Program Files\App\" directory.
That is Vista's "File System Virtualization" feature at work:
http://msdn2.microsoft.com/en-us/library/bb756960.aspx
Refer to the "Virtualization" section.
> My app when runs checks for the directory and create some directories in
> the "C:\Program Files\App\" if not exist. XP it was working fine.
You should not be creating folders and files under "Program Files" to begin
with. Create them in the CSIDL_APPDATA, CSIDL_LOCAL_APPDATA, or
CSIDL_COMMON_APPDATA folder instead, depending on your needs. Use
SHGetSpecialFolderLocation() or similar function to resolve those IDs to
physical paths.
> In vista if i delete the sub directories under "C:\Program Files\App\"
> manually. The program is considering the "Virtual Store\Program
> Files\App\" path as a app folder path and i don't have any control over
> the
> "C:\Program Files\App\" directory to create sub directories.
Because you are not supposed to be writing anything there to begin with, so
Vista is making sure you don't.
> But anyhow i changed the app subdirectories path for the below.
> XP -C:\Documents and Settings\All Users\Application Data\App\SubDirectory
> Vista - C:\Program Data\App\SubDirectory.
That is the CSIDL_COMMON_APPDATA folder.
> Is this recommended. I need my app sub directories for all users,
> instead of creating for each user.
Yes, CSIDL_COMMON_APPDATA is appropriate for that purpose.
Gambit
Re: Delete File
Author: bar
Date: Fri, 18 Apr 2008 11:49
Date: Fri, 18 Apr 2008 11:49
2 lines
1031 bytes
1031 bytes
Thanks Remy. I really appreciate your suggestions..
Re: Delete File
Author: bar
Date: Mon, 21 Apr 2008 14:18
Date: Mon, 21 Apr 2008 14:18
44 lines
2191 bytes
2191 bytes
Thanks everyone for the comments.
I have to post my problem once again.
I used this code
//Unit1.cpp file
#define NO_WIN32_LEAN_AND_MEAN
#include <shlobj.h>
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
...
...
//In a button click event i have.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
LPITEMIDLIST List = NULL;
char Path[MAX_PATH + 1] = {0};
if(SUCCEEDED(SHGetSpecialFolderLocation(0,CSIDL_COMMON_APPDATA, &List)))
{
if(SHGetPathFromIDList(List, Path))
ShowMessage(String(Path));
}
else
ShowMessage("SHGetSpecialFolderLocation failed");
CoTaskMemFree(List);
}
1 .Compile the code i have the following error messages.
[C++ Error] winsock2.h(109): E2238 Multiple declaration for 'fd_set'
[C++ Error] winsock.h(54): E2344 Earlier declaration of 'fd_set'
[C++ Error] winsock2.h(112): E2146 Need an identifier to declare
[C++ Error] winsock2.h(153): E2238 Multiple declaration for 'timeval'
[C++ Error] winsock.h(97): E2344 Earlier declaration of 'timeval'
[C++ Error] winsock2.h(209): E2238 Multiple declaration for 'hostent'
[C++ Error] winsock.h(153): E2344 Earlier declaration of 'hostent'
Re: Delete File
Author: DreamChaser
Date: Mon, 21 Apr 2008 17:48
Date: Mon, 21 Apr 2008 17:48
12 lines
1241 bytes
1241 bytes
bar wrote: > Thanks everyone for the comments. > > I have to post my problem once again. > > I used this code > > //Unit1.cpp file > > #define NO_WIN32_LEAN_AND_MEAN This needs to be in the Project Compiler conditionals.
Re: Delete File
Author: Bob Gonder
Date: Mon, 21 Apr 2008 21:34
Date: Mon, 21 Apr 2008 21:34
30 lines
1825 bytes
1825 bytes
bar wrote: >//Unit1.cpp file > >#define NO_WIN32_LEAN_AND_MEAN >#include <shlobj.h> > >#include <vcl.h> >#pragma hdrstop > >#include "Unit1.h" >... >... > > if(SUCCEEDED(SHGetSpecialFolderLocation(0,CSIDL_COMMON_APPDATA, &List))) >[C++ Error] winsock2.h(109): E2238 Multiple declaration for 'fd_set' >[C++ Error] winsock.h(54): E2344 Earlier declaration of 'fd_set' Winsock has nothing to do with SHGet... and is a seperate problem. Somewhere in your deleted #includes, you have winsock.h being included before winsock2.h Include winsock2.h first, probably before vcl.h. Or make sure _WIN32_WINNT >= 0x0400 (See in windows.h where it includes winsock2.h, and the conditions that cause it to prefer version 2 over winsock.h)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads