Skip to content

CountJung/WPF-App-with-CPP-via-MemoryMappedFile

Repository files navigation

WpfWithCppInMmf

this Code is Written in Visual Studio 2022

Simple Way to Code WPF With CPP DataContext Switching via MMF

Basic Concept shown as below image

WPFWithCPPInMMF

1. What is the purpose of this code?

More than decades, Windows Developer had Suffered alot about User Interface area because have restricted choice about it. Microsoft Windows Class(MFC) have used for more than 20 years as UI Application Program And now even MS abandoned of that.

late days, almost of windows developer uses C# in .NET Framework. it is standard solution now, but some case we have to use C/C++ code to build an Application Using massive native code based Library Project.

C/C++ Code may Marshalled for using in C# but it Costs lots of time. So, This Sample shows VerySimple way to use C/C++ code with WPF(C#) context by Using Memory Mapped File.

2. Check point of this project

  • shared Structure
struct SharedData
{
	int integerData;       //4 byte
	double doubleData;     //8 byte
	char stringData[256];  //256 byte
};
    public struct SharedData
    {
        public int integerData;                      //4 byte
        public double doubleData;                    //8 byte
        public byte stringData;                      //assume 256 byte, plus whole padding bytes
    }
  • if you don't want to calculate data padding then just get sizeof(structure) in CPP code and assign bytes to C# code, that's easy and fast.

  • Quick Calculation - (double 8 Byte is minimum byte padding)

    (4+8+256) = 268 / 8 = 33.5
    (4+8+256) + 4 = 272 / 8 = 34

About

Simple Way to Code WPF With CPP DataContext Switching via MMF

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published