C#调用VC编写的DLL(给分)
新手提问,用vc封装了一个dll,但是在c#中调用时,dll只得到一个字符。请高手给与解答,谢谢!!
这段是我用vc写的dll的程序
//Export.cpp
include "stdafx.h"
#include "AppApi.h"
static CString GetTempName(CString strPath);
BOOL WINAPI OnSend(CString strNumber)
{
AfxMessageBox(strNumber);
return true;
}
//ApppApi.h
#ifdef __cplusplus
extern "C" {
#endif
/* __cplusplus */
struct SmsData
{
BOOL bSmsFullScreen;
char szSmsPath[MAX_PATH]; // no unicode path support
char szSmsFilename[MAX_PATH];
};
BOOL WINAPI OnSend(CString strNumber);
#ifdef __cplusplus
}
#endif
下面是c#的程序
//
[DllImport("Sms.dll", EntryPoint="OnSend",CharSet=CharSet.Auto)]
public static extern int OnSend(string phone);
private void button1_Click(object sender, System.EventArgs e)
{
string AA;
AA=textBox1.Text;
try
{
Form1.OnSend(AA);
}
catch( EntryPointNotFoundException)
{
}
}
谢谢各位大虾了