-1
        private void discord_click(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Minimized;
            Process objProcess = new Process();
            objProcess.StartInfo.FileName = "Update.exe.lnk";
            objProcess.StartInfo.Arguments = @"C:\Users\Darksli\Desktop\folders\MainApp\MainApp\MainApp\bin\Debug\links\";
            objProcess.Start();
        }

If i press button i see error "Can't find this file"

Anonymous
  • 5
  • 5

1 Answers1

0

You could try to refer to the steps below to see if it suits you. Project A:

MainWindow.xaml:

<Grid>
    <Button Click="Button_Click" Width="100" Height="40" Content="click"/>
</Grid>

MainWindow.xaml.cs:

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;

namespace ClickButtonToOpenProgram
{
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
      Process p = Process.Start("BackgroundOfCanvas");
      p.WaitForInputIdle();
      SetParent(p.MainWindowHandle, Process.GetCurrentProcess().MainWindowHandle);
    }

    [DllImport("user32.dll")]
    static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
  }
}

Project B:

<Canvas Opacity="0.9">
     <Path Fill="Black" Data="M0,0 L1000,0 1000,1000 0,1000Z M100,100 L200,100 200,200 100,200Z"/>
     <Rectangle Fill="LightGreen" Height="100" Width="100" Margin="200"/>
     <TextBlock Text="hello" Background="AliceBlue" Height="40" Width="100" />
</Canvas>

Right-click the Reference of Project A, select Add Reference... and then check Project B.Finally click Ok.

The result

Frankich
  • 842
  • 9
  • 19
LSQ
  • 52
  • 9
  • HI,@ Darksli.Are there any updates to the question? Do you have time to check if my answer fits you? – LSQ Dec 22 '21 at 08:31