Conversation

On demand elevation in Delphi applicatio to create folder in 'ProgramFiles' folder [Edit]

(overview of excerpts from articles in conversation)

Newsgroup: embarcadero.public.delphi.com.activex.using

# Lines
wrote on 11-Apr-2013:

Hello all,
I'd like the have a on demand elevation of an filesystem COM object, so I
can delete/rename/create items in the 'Program Fiels' folder.
So far I found some code about running a 'out of process' COM object with
evevated rights (see code below)
75
  
Remy Lebeau (TeamB) replied on 11-Apr-2013:

Ronald wrote:
  (snip)

You must create the COM object using the COM Elevation Moniker, and the COM
  object needs to be registered to support elevation. See MSDN for more details:
  http://msdn.microsoft.com/en-us/library/windows/desktop/ms679687.aspx
  (snip)

And the problem is...? You use the same CLSID/IID values that you would
27
    
Ronald Hoek replied on 12-Apr-2013:

{quote:title=Remy Lebeau (TeamB) wrote:}
    And the problem is...? You use the same CLSID/IID values that you would
    use with CoCreateInstance() when creating the COM object without elevation.
    {quote}
    OK, let me reframe the question: what I would like to have is an Interface/ClassID to a default Windows COM object, which can perform 'file system' operation AND be elevated.
20
      
Remy Lebeau (TeamB) replied on 14-Apr-2013:

Ronald wrote:
      (snip)

There is no such COM object built-in to Windows. You have to write your
      own COM object based on your particular needs.
      --
      Remy Lebeau (TeamB)
14
        
Ronald Hoek replied on 15-Apr-2013:

(snip)

To bad, but thanks for the info...
        But how does Windows do it itself - regarding the 'explorer.exe' process?
        - I just want the same functionality as it does (copy/past/rename/create etc.)
        Edited by: Ronald Hoek on Apr 15, 2013 2:20 AM
        
14
          
Remy Lebeau (TeamB) replied on 15-Apr-2013:

Ronald wrote:
          (snip)

Explorer is a user-space app like any other. The same rules of elevation
          apply to it. It has a UAC manifest that requests "asInvoker" privileges.
          Which means if the user that is running Explorer has permissions to invoke
          those filesystem operations on a given file, then Explorer will be able to
22
            
Ronald Hoek replied on 16-Apr-2013:

(snip)

But when deleting a file in the 'program files' folder, it is elevated.
            Does it use COM at that point or does it just elevate the 'explorer.exe' with some command line parameters?
            Is command line parameters are the way, can someone point me to a page, where I can find these so I can use an elevated 'explorer.exe' to delete/create files/folders inside the 'program files' folder (or any other admin privilege required folder).
            
            
32
  
Ronald Hoek replied on 15-Apr-2013:

Reopende the question, with the 'explorer.exe' features in mind.
  
  
  
  
2
  
Ivayllo Georgiev replied on 16-Apr-2013:

On 11.04.2013 г. 11:17 ч., Ronald Hoek wrote:
  (snip)

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775771(v=vs.85).aspx
  Regards.
  
  
78
  
Ronald Hoek replied on 16-Apr-2013:

Found the solution:
  {code}
  procedure TestFolderCraeation(sDir: string);
  var
  lFileOp: IFileOperation;
78
  
Ronald Hoek replied on 16-Apr-2013:

Found answer be searching on 'elevation' and 'IFileOperation' object/interface
  
  
  
  
3
    
Remy Lebeau (TeamB) replied on 16-Apr-2013:

Ronald wrote:
    (snip)

Good catch.
    --
    Remy Lebeau (TeamB)
    
6
      
Ronald Hoek replied on 19-Apr-2013:

(snip)
I don't deserve all the credit, but thanks. Found most info on this on the internet en commented it so more users can directly comprehend the code ;)
      
      
      
      
6
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Tue, 19 Nov 2024 14:43:23 UTC
Copyright © 2009-2024
HREF Tools Corp.