ByLiZhao / code_sample_win_platform

This project contains code samples of C++ and C# code on windows platform, mainly MSVS projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

code_sample_win_platform

This project contains code samples in C++ and C# on windows platform in form os MSVS solutions and projects

  • Named pipe example in C#, a server and a client, in c_sharp/named_pipe_client.
  • Normal distributed random number generator in C3, using the Box-Muller algorithmin /c_sharp/normal_distribution/.
  • A dll class written in C++, which operates on an unique device connected to the PC. A C# class which wrap the dll and marshal all call to the dll is built upon it. Assuming that the device returns RGGB Bayer format as part of data retrived from the device, the wrapper class also performs conversion to normal Bitmaps.
  • A simple csv writer class is contained in cpp/csv_writer.
  • Example in folder /cpp/wrap_rs_dll/ demonstrate how to embed a binary image of a file to a dll. Please note that the method is different from using resource files in a VC++ project as described in this MSDN page. Our method employ a code generator which generates a head file. In the head file, a const global array is explicitly defined that is a binary copy of the original file. The header file is then used to generate a dll. The resulted dll will contain the file in it. The caller of that dll can use the exported functions of the dll to access that file.
  • The /cpp/deleter/ folder contains a minimal example to demonstrate how to use deleter function to make memory owership transferring between binary boundary safe. When working with a dyanmic library, if the caller has no control on its source code, it is possible that the dll runs with a different C++ runtime than the calller. When memory ownership is transferred between the caller and the callee, meaning memory allocated in the dll will be freed in the caller's side, sometimes causes nasty problems. It is safer for the dll to expose a deleter function, and the caller use it to safely free an object, its ownership being previously transferred from the dll to the caller. The cpp/circular_buffer folder constains a minimalistic implementation of circular buffers, which is lock-free while the buffer is not full or empty.

About

This project contains code samples of C++ and C# code on windows platform, mainly MSVS projects


Languages

Language:Objective-C 98.9%Language:C# 0.5%Language:C++ 0.5%Language:C 0.1%