本文介绍了如何从本机dll接收字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

请告诉我如何从本地dll(用EVC ++编写)将字符串接收到紧凑的C#项目中.

请举例说明.

提前致谢.
bikram singh

Hello everybody

Please tell me of how can i receive a string from a native dll (written in EVC++) into a compact C# project.

Please explain with example.

Thanks in advance.
bikram singh

推荐答案

//C++ function syntax ->     int GetWindowText( HWND hWnd, LPTSTR lpString, int nMaxCount );
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

//Form's button click event.
private void button1_Click(object sender, EventArgs e)
{
    const int nMaxCount = 255;
    StringBuilder str = new StringBuilder(nMaxCount);
    GetWindowText(this.Handle, str, nMaxCount);
}



这篇关于如何从本机dll接收字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:31