/**/
/*==C==*/
__declspec(dllexport) long __stdcall
PrintMsg( char * name)
... {
if (name == NULL)
return -1;
printf("Hello,%s",name);
return 0;
}
Complile ==> test1.dll
/**/ /*==C#==*/
class Program
... {
//调用C DLL 中的函数
[DllImport("test1.dll",EntryPoint="PrintMsg",CharSet=CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]
public static extern void PrintMsg(char[] name);
static void Main(string[] args)
...{
char[] name = "ZestA".ToCharArray();
PrintMsg(name);
Console.Read();
}
}
__declspec(dllexport) long __stdcall
PrintMsg( char * name)
... {
if (name == NULL)
return -1;
printf("Hello,%s",name);
return 0;
}
Complile ==> test1.dll
/**/ /*==C#==*/
class Program
... {
//调用C DLL 中的函数
[DllImport("test1.dll",EntryPoint="PrintMsg",CharSet=CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]
public static extern void PrintMsg(char[] name);
static void Main(string[] args)
...{
char[] name = "ZestA".ToCharArray();
PrintMsg(name);
Console.Read();
}
}