c++ - How to shellexecute a tempory installer file? -


shellexecuteinfo shexecinfo;  shexecinfo.cbsize = sizeof(shellexecuteinfo);  shexecinfo.fmask = null; shexecinfo.hwnd = null; shexecinfo.lpverb = _t("runas"); shexecinfo.lpfile = filepath; shexecinfo.lpparameters = null; shexecinfo.lpdirectory = null; shexecinfo.nshow = sw_maximize; shexecinfo.hinstapp = null;  shellexecuteex(&shexecinfo); 

if filepath temp file downloaded internet, shellexecuteex fail. if filepath normal file name such "notepad", works.

i conclude shellexecute need right extension name, normal privilege app not write executable file system partion such c:\users\xxx\local\temp\xxx.exe.

the error code error_no_association.

please me solve contradiction.

the error system returning error_no_association. although have not stated extension filepath has, seems not .exe.

were rename downloaded file have extension .exe, call shellexecuteex succeed. that's hacky way it. cleaner way use lpclass member of shellexecuteinfo struct specify want file treated executable. can adding following code:

shexecinfo.fmask = see_mask_classname; shexecinfo.lpclass = _t("exefile"); 

i'd write code this:

shellexecuteinfo shexecinfo = {0}; shexecinfo.cbsize = sizeof(shellexecuteinfo); shexecinfo.fmask = see_mask_classname; shexecinfo.lpverb = _t("runas"); shexecinfo.lpfile = filepath; shexecinfo.nshow = sw_maximize; shexecinfo.lpclass = _t("exefile"); shellexecuteex(&shexecinfo); 

note 0 initialization can omit explicit assignment members should null.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -