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.
I believe shellExecute does require admin. You didn't mention the OS. If it is Vista+ then UAC comes in to play. see this explanation
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.
精彩评论