сделал в таком виде:
функция в dll (примерная)
| Код | extern "C" __declspec(dllexport) int __stdcall MyMessage(TCHAR * chstr) { MessageBox(NULL, chstr, _T("Message from DLL"), MB_OK); TCHAR * tchstr = _T("Let's my people go"); _tcscpy(chstr, tchstr ); return 0;
|
cs файл | Код | [DllImport ("C:\\job\\SimpleDLL\\debug\\simpledll.dll")] static extern int MyMessage(IntPtr intptr);
static void Main(string[] args) { string str = "Опаньки!"; IntPtr intptr = Marshal.AllocHGlobal(2048); Marshal.Copy(str.ToCharArray(), 0, intptr, 8); MyMessage(intptr); string ts = Marshal.PtrToStringUni(intptr);
|
|