wpfwinapiwpf-controls

WPF-win32 Interoperation


I have a win32 project which is very complex and i successfully referenced that in my wpf.
Now my Question i have created a dialogue in wpf which select a file,but the function which process this file written in win32 part of my project. is it possible to access a particular function written in win32 part in wpf?


Solution

  • Yes you can. It doesn't have limitations in using classes (because they are still written in C#, right?)

    upd: if you want to call native win32 function, create a wrapper, e.g.

    using System.Runtime.InteropServices;

    public class Win32Interop
    {
        [DllImport("YourWin32Library.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern void ProcessFile(string filePath);
    }
    

    and call it from your project

    string filePath = "path_to_your_file.txt";
    Win32Interop.ProcessFile(filePath);