hi,
i have a dll which i made of a C program..
#include <stdio.h>
extern "C"
{
__declspec(dlle xport) void DisplayHelloFro mDLL(char *input,char *output )
// int n;
{
// char *name = "";
//*name = *input;
printf ("Hello from DLL !\n");
printf ("string is %s", input);
output = input;
}
}
now i need to call this function from the C# code...
using System;
using System.Runtime. InteropServices ;
class HelloWorld
{
[DllImport("test 1.dll")]
public static extern void DisplayHelloFro mDLL(System.Str ing i,System.String o);
static void Main ()
{
Console.WriteLi ne ("This is C# program");
System.String i = "teststring ";
System.String o = "";
DisplayHelloFro mDLL (i,o);
Console.WriteLi ne("output is {0}",o);
}
}
Can anyone tell me how can i pass the string parameter to C function where it is accepting it as char* ... there are 2 variables... one is input and other one is output which i need to get the value back in C#.
i have a dll which i made of a C program..
#include <stdio.h>
extern "C"
{
__declspec(dlle xport) void DisplayHelloFro mDLL(char *input,char *output )
// int n;
{
// char *name = "";
//*name = *input;
printf ("Hello from DLL !\n");
printf ("string is %s", input);
output = input;
}
}
now i need to call this function from the C# code...
using System;
using System.Runtime. InteropServices ;
class HelloWorld
{
[DllImport("test 1.dll")]
public static extern void DisplayHelloFro mDLL(System.Str ing i,System.String o);
static void Main ()
{
Console.WriteLi ne ("This is C# program");
System.String i = "teststring ";
System.String o = "";
DisplayHelloFro mDLL (i,o);
Console.WriteLi ne("output is {0}",o);
}
}
Can anyone tell me how can i pass the string parameter to C function where it is accepting it as char* ... there are 2 variables... one is input and other one is output which i need to get the value back in C#.
Comment