How to use the result of a call to GetFileSecurity?

Hi,

My overall task is to determine if the current user can write to a given
folder (i.e. C:\Program Files\MyApp). Up until now I have just tried to
write a file in the folder to determine this.
However on Vista with UAC enabled this will flag my application as "not
compatible" when someone tests it with the Vista Compatibility Tool.

I have found the API function GetFileSecurity and can call it just fine.
However I am a novice with ACL and ACE etc. so how what I need to find out
is how to use the result of the function to determine if the current user
has permissions to write to the folder. Does anybody know where I can find a
working example or have any other pointers?

Thanks in advance.

-- 
Best regards,

Lars Sondergaard
0
Lars
8/18/2008 7:11:58 PM
embarcadero.delphi.nativeapi 1236 articles. 1 followers. Follow

2 Replies
1644 Views

Similar Articles

[PageSpeed] 43
Get it on Google Play
Get it on Apple App Store

Lars Sondergaard schrieb:
> Hi,
> 
> My overall task is to determine if the current user can write to a given
> folder (i.e. C:\Program Files\MyApp). Up until now I have just tried to
> write a file in the folder to determine this.
> However on Vista with UAC enabled this will flag my application as "not
> compatible" when someone tests it with the Vista Compatibility Tool.
> 
> I have found the API function GetFileSecurity and can call it just fine.
> However I am a novice with ACL and ACE etc. so how what I need to find out
> is how to use the result of the function to determine if the current user
> has permissions to write to the folder. Does anybody know where I can find a
> working example or have any other pointers?
> 

I think you should just add a Vista manifest into your application.
Didn't you?
Secondly, you should check the logs of VCTool. It tells what is
problematic with your app.

Otherwise you could try the JEDI Windows Security Code Library, since it
 encapsulates all the C API calls
(http://jwscldoc.delphi-jedi.net/JwsclSecureObjects.TJwSecureFileObject.html)
There is even a small sample :
http://jedi-apilib.svn.sourceforge.net/viewvc/jedi-apilib/jwscl/branches/0.9.1/examples/FileSecurity/Get/ReadFileSecurity.dpr?revision=433&view=markup
I guess the same code with C-API calls would need hundreds of lines of code.

-- 
Christian Wimmer
http://blog.delphi-jedi.net/
0
Christian
8/18/2008 8:02:04 PM
Christian Wimmer schrieb:
> 
> I think you should just add a Vista manifest into your application.
> Didn't you?
> Secondly, you should check the logs of VCTool. It tells what is
> problematic with your app.
> 
> Otherwise you could try the JEDI Windows Security Code Library, since it
>  encapsulates all the C API calls
> (http://jwscldoc.delphi-jedi.net/JwsclSecureObjects.TJwSecureFileObject.html)
> There is even a small sample :
> http://jedi-apilib.svn.sourceforge.net/viewvc/jedi-apilib/jwscl/branches/0.9.1/examples/FileSecurity/Get/ReadFileSecurity.dpr?revision=433&view=markup
> I guess the same code with C-API calls would need hundreds of lines of code.
> 

Just want to know:
Wasn't my answer sufficient?

-- 
Christian Wimmer
http://blog.delphi-jedi.net/
0
Christian
8/26/2008 8:26:07 PM
Reply:

Similar Artilces:

Trying to call a .DLL from Delphi XE (used to work with Delphi 6 :-) )
Hi everyone, I have a problem where perhaps some one could help point me in the right direction. In Delphi 6 I used a stand alone package to train a neural netowrk,. The trained neural network was stored as a .DEF file. The standalone software provided a .DLL and Delphi code to call the network and get the prediced values from your sw. (The .DLL was created in 2002 and apparently is 32 bit.) I have'nt used it for years but am now coming back to it.... I now use Delphi XE on Windows 7 (32 bit) The old .exe's I had compiled from that time work fine. However in Delphi XE ...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

Duplicate result using DELPHI and SQLAW
Assume a table Test with column ID CHAR(30) primary key put 6 records with string containing the letter '_' in the column ID Create a DBGrid in Delphi using the primary key as index You will see 12 records If you have an Idea , call me Thanks >Assume a table Test with column ID CHAR(30) primary key >put 6 records with string containing the letter '_' in the column ID >Create a DBGrid in Delphi using the primary key as index >You will see 12 records >If you have an Idea , call me Can you determin the exact SQL statement that d...

What calling convention does 64-bit Delphi use?
Just came across this webpage: http://msdn.microsoft.com/en-us/library/ms235286(v=vs.100).aspx *Given the expanded register set, x64 just uses the __fastcall calling convention and a RISC-based exception-handling model.* Does this mean 64-bit Windows DLLs now export functions using __fastcall instead of stdcall for Win32? > Does this mean 64-bit Windows DLLs now export functions using __fastcall instead of stdcall for Win32? There's only one calling convention under Win64. With both MSVC and Delphi 64bit compliers, calling convention specifiers are just ignored. Simon ...

URGENT:: Using Result Set from Stored Procedures Calls
Hi, my problem arises when writing a stored procedure that need to use the result set produced by another stored procedure. I don't know how to access the result set produced by the other stored procedure. For example: .... T/SQL CODE DECLARE @retcode int ; EXEC @retcode = sp_fkeys 'TABLE_NAME' -- AND NOW ? HOW CAN I ACCESS THE RESULT SET PRODUCED -- BY THE sp_fkeys call ???? ..... Thanks for any help. Giacomo Fiorentini This is a multi-part message in MIME format. --------------4AC43376201C724AFB8348B1 Content-Type: text/plain; charset=u...

Using a TableAdapter to call multiple results from a Stored Procedure
Hi,I use a Table Adapter to call the results from a Stored Procedure but I only get the result from the first Exec display_location_#temp No results are displayed from Exec display_Author_#temp and  Exec display_Icon_#tempWhat should I change, to the Stored Procedure create_table_#temp so all the called results are displayed?   StoredProcedure create_table_#temp CREATE TABLE #Temp( Filenumber int, Icon image, Date datetime, Location nvarchar(50), author nvarchar(75) )   Begin Insert Into #Temp Select Filenumber, Icon, D...

Using a TableAdapter to call multiple results from a Stored Procedure
Hi,I use a Table Adapter to call the results from a Stored Procedure but I only get the result from the first Exec display_location_#temp No results are displayed from Exec display_Author_#temp and  Exec display_Icon_#tempWhat should I change, to the Stored Procedure create_table_#temp so all the called results are displayed?   StoredProcedure create_table_#temp CREATE TABLE #Temp( Filenumber int, Icon image, Date datetime, Location nvarchar(50), author nvarchar(75) )   Begin Insert Into #Temp Select...

How to use powerbuilder call DOS command and get the result from DOS
Dear all, I have a problem, I want write script to call DOS command - "vol" and get the result from DOS, how to ????? Use the corresponding Win32 API function -- GetVolumeInformationA(). FUNCTION boolean GetVolumeInformationA ( string lpRootPathName, // root directory REF string lpVolumeNameBuffer, // volume name buffer ulong nVolumeNameSize, // length of name buffer REF ulong lpVolumeSerialNumber, // volume serial number REF ulong lpMaximumComponentLength, // maximum file name length REF ulong lpFileSystemFlags, // fil...

Can Delphi call Cocoa framework methods that use code block parameters?
I have been investigating whether it is possible to call the ExternalAccessory framework from Delphi XE5. I am trying to write an interface unit for this framework, and I have run up against the code block data type in Objective-C. For example, in the EAAcessoryManager.h header file we see this declaration: typedef void(^EABluetoothAccessoryPickerCompletion)(NSError *error); If I understand this syntax correctly, this declares the identifier EABluetoothAccessoryPickerCompletion as a pointer to a code block that takes an NSError object parameter and returns a void (i.e. acts as a proced...

Using Delphi 7 and Delphi 2010
I had a project in Delphi 7. I worked on it in Delphi 2010. When I try to open the .dpr again in Delphi 7, the IDE toolbar widens across both monitors, and Delphi 7 locks up. It appears that Delphi 2010 modifies the .dpr in a way that makes Delphi 7 unable to open it again. All my forms & units appear to open fine in D7 after D2010, except for the warnings on the ExplicitHeight and ExplicitWidth properties being missing... I can easily recreate the .dpr, but is this expected behavior? Thanks. Tom Field wrote: > I had a project in Delphi 7. > > I worked o...

Calling C++ DLL call from Delphi
Hi All I have C++ DLL setup that exports the following function: bool ApplyRule(HANDLE DriverDevice, std::string *Path, PROTECTION_TYPE Type, PROTECTION_ACTION Action, bool Architecture64, bool AddRule) I am not sure how to convert it properly to delphi, inparticular the std::string parameter. ApplyRule : function (DriverDevice : THandle; Path : ????; Kind : PROTECTION_TYPE; Action : PROTECTION_ACTION; Architecture64 : Boolean; AddRule : Boolean) : boolean; stdcall; Thanks for the help. Chris Nillissen wrote: > I am not sure how to convert it properly to delphi,...

result value not used when using Raise?
I get a compiler warning that the return value of a function is not used, when I use Raise in the onException. I do not understand how that is possible, as there are two places where the function will exit before getting to the end (as far as I understand). The intention of Raise is that it will be handled the next level up, right? Which is what I want. {code} function TTeamReference.LoadStream(AnsiReader: TAnsiReader):boolean; var AVersion, AFooter: integer; begin result := false; << Compiler warning: [dcc32 Hint] TeamSetupU.pas(207): H2077 Value assigned to 'TTeamRe...

superreview granted: [Bug 242990] Crash when LDAP query results content none UTF8 characters : [Attachment 147958] If the result strings IsUTF8 use UTF8ToNewUnicode, otherwise use general ToNewUnicod
Dan Mosedale <dmose@mozilla.org> has granted wind li <wind.li@sun.com>'s request for superreview: Bug 242990: Crash when LDAP query results content none UTF8 characters http://bugzilla.mozilla.org/show_bug.cgi?id=242990 Attachment 147958: If the result strings IsUTF8 use UTF8ToNewUnicode, otherwise use general ToNewUnicode http://bugzilla.mozilla.org/attachment.cgi?id=147958&action=edit ------- Additional Comments from Dan Mosedale <dmose@mozilla.org> r+sr=dmose ...

superreview requested: [Bug 242990] Crash when LDAP query results content none UTF8 characters : [Attachment 147958] If the result strings IsUTF8 use UTF8ToNewUnicode, otherwise use general ToNewUnic
wind li <wind.li@sun.com> has asked Dan Mosedale <dmose@mozilla.org> for superreview: Bug 242990: Crash when LDAP query results content none UTF8 characters http://bugzilla.mozilla.org/show_bug.cgi?id=242990 Attachment 147958: If the result strings IsUTF8 use UTF8ToNewUnicode, otherwise use general ToNewUnicode http://bugzilla.mozilla.org/attachment.cgi?id=147958&action=edit ...

Web resources about - How to use the result of a call to GetFileSecurity? - embarcadero.delphi.nativeapi

Resources last updated: 12/7/2015 12:03:04 AM