Byte型とChar型のデータのやりとり
#include <windows.h> #include <cstddef> #include <iostream> using namespace std; #define DLLEXPORT __declspec(dllexport) WINAPI // BYTE受け取り extern "C" void DLLEXPORT dllbyte(const BYTE a) { cout << a << "," << (int)a << endl; } // Char受け取り extern "C" void DLLEXPORT dllchar(const char b) { cout << b << endl; }
using System; using System.Runtime.InteropServices; namespace test1 { internal class Program { [DllImport("Dll1.dll")] static extern void dllbyte(byte a); [DllImport("Dll1.dll")] static extern void dllchar(char b); static void Main(string[] args) { byte a = 0x41; dllbyte(a); char b = 'b'; dllchar(b); Console.ReadKey(); } } }