Jump to content

Windows Paint 3D open file using ShellExecute

Recommended Posts

I am running  ShellExecute(0, 'open', 'ms-paint:', PChar(FilePath), nil, SW_SHOWNORMAL) ,

Paint 3D is open but the file is missing ??? , with  mspaint is working or other painting program

What is the correct command ???


Thank you Vagelis Bekyros

Share this post

Link to post

A couple of things to check: 1) are you providing the full path to the file? 2) If there are any spaces in the path, it needs to be enclosed in double-quotes.

You should also be able to check the return value to understand if there are errors.

Share this post

Link to post

Why are you using ShellExecute. That's a deprecated function that used to be used to execute shell actions, but has been replaced by ShellExecuteEx. If you want to execute a specific program why aren't you using CreateProcess?

Share this post

Link to post

 procedure OpenImageWithPaint3D(const FilePath: string);
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  AppName: string;

  CreateOK: Boolean;
 // ShellExecute(0, 'open', 'ms-paint:', PChar(FilePath +' /ForceBootstrapPaint3D'), nil, SW_SHOWNORMAL);
 // ShellExecute(0, 'open', 'mspaint', PChar(FilePath), nil, SW_SHOWNORMAL);
   AppName := 'mspaint';
  ZeroMemory(@StartupInfo, SizeOf(TStartupInfo));
  StartupInfo.cb := SizeOf(TStartupInfo);
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := SW_SHOWNORMAL;

  CreateOK := CreateProcess(nil, PChar(AppName + ' ' + FilePath), nil, nil, False, 0, nil, nil, StartupInfo, ProcessInfo);
  if CreateOK then
    // Successfully created the process
    // Failed to create the process
    MsgInformation('Failed to open the file with Paint 3D.');



This function is working for mspaint 

Paint 3D is a modern app, which doesn't use executables like older classic applications. With var AppName what i use ????


Share this post

Link to post

Based on this, you can use the old paint.exe to force-launch the new Paint 3D:


mspaint "C:\TEMP\A.jpg" /ForceBootstrapPaint3D


As far as I know though even "modern" apps have executables they just reside in unimaginable places somewhere under your local appdata folder.

Unfortunately though I can not confirm this as Paint 3D is one of the first things I uninstall from a new Windows 🙂

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now