delphi - Can't open bitmap file using default program -


i have form has timage component on displays images directory. clicking timage component opens file using default program.

for example, clicking jpeg image file launch windows photo viewer.
reason when clicking bitmap image file doesn't open, doesn't anything.
opening file outside program through windows open via windows photo viewer.

below code i'm doing when clicking timage component.

procedure tfrmcase.imageclick(sender: tobject); begin   shellexecute(handle, 'open',pchar(filen), nil,nil,sw_shownormal) ; end; 

you have known wrong if had done error checking david suggested.

check following code:

uses   winapi.shellapi;  procedure tform22.button1click(sender: tobject); var   command: string;   info: tshellexecuteinfo;   myfilename: string; begin   myfilename:= 'c:\windows\syswow64\oobe\background.bmp';   fillchar(info,sizeof(info),#0);   info.cbsize:= sizeof(info);   info.fmask:= see_mask_default;   info.lpfile:= pwidechar(myfilename);   info.nshow:= sw_normal;   //info.lpverb:= 'open';     win32check(shellexecuteex(@info)); end; 

this works fine default verb.

the info shellexecuteex here: https://msdn.microsoft.com/en-us/library/windows/desktop/bb759784%28v=vs.85%29.aspx
, here: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762154%28v=vs.85%29.aspx

always remember 0 record fillchar(info,sizeof(info),#0);, because stack can , contain random garbage.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -