BCB:

 

#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------

extern "C" __declspec(dllexport) char* importStr(AnsiString str1)   
{
 return str1.c_str();          //把AnsiString转换为char*,返回char*类型 
}

 

 

C#:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    class Program
    {
        [DllImport("C:\test.dll")]

        public static extern StringBuilder _importStr(String str1);

        static void Main(string[] args)
        {
            Console.WriteLine(_importStr("hello world1").ToString());
        }
    }
}

相关文章:

  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-08-05
  • 2021-09-29
  • 2022-12-23
猜你喜欢
  • 2021-06-16
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
相关资源
相似解决方案