Search code examples
delphishellexecute

When could ShellExecute fail? (Delphi)


I am planning to use ShellExecute for the updater of an application written in delphi 2007, I was wondering if ShellExecute will work on most computers with Win or if it can easly fail because of some user permission or something like that.


Solution

  • From MSDN

    Remarks

    Because ShellExecute can delegate execution to Shell extensions (data sources, context menu handlers, verb implementations) that are activated using Component Object Model (COM), COM should be initialized before ShellExecute is called. Some Shell extensions require the COM single-threaded apartment (STA) type. In that case, COM should be initialized as shown here:

    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
    

    And as Ken Lange alread suggested, deppending on what you want to execute, you may need administrative rights.