ShellExecuteEx and Coinitialize in VCL thread

前端 未结 3 1008
悲哀的现实
悲哀的现实 2021-01-13 06:09

Do I need to call Coinitialize in the main/VCL thread in Delphi before using ShellExecuteEx?

For a thread, yes but for the VCL thread ?

3条回答
  •  一向
    一向 (楼主)
    2021-01-13 06:31

    No need to call CoInitialize for Windows Forms Applications. This is done for you in the main thread. More specific TApplication.Create in Forms.Pas:

    ...
    if not IsLibrary then
     FNeedToUninitialize := Succeeded(OleInitialize(nil));
    ...
    

提交回复
热议问题