string 형식 함수 bcb dll, c# 호출

1087 단어 String 클래스
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());
        }
    }
}


좋은 웹페이지 즐겨찾기