Re: Calling dll functions
- From: "Mythran" <kip_potter@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Apr 2006 15:48:06 -0700
"sb" <stormfire1@xxxxxxxxx> wrote in message news:u7ekkEMZGHA.4652@xxxxxxxxxxxxxxxxxxxxxxx
btw: you don't need to declare "Num" as an out parameter unless the DLL plans to change it.
-sb
"Mythran" <kip_potter@xxxxxxxxxxxxxxxxxxxxxx> wrote in message news:uDpQt5JZGHA.1348@xxxxxxxxxxxxxxxxxxxxxxx
"John" <John@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:0F784C81-9ED4-425D-8ADF-89BF15762C3A@xxxxxxxxxxxxxxxxDWORD _stdcall DLLFunction(DWORD Num, CHAR *Str);
I call the above dll function from a C++ app. Now I need to call it from my
C# app. How can I do it?
[DllImport("MyDll.dll")]
public static extern int DLLFunction(int Num, string Info);
int Num;
string Info = new string(' ', 80);
DLLFunction(Num, Info);
I cannot get anything in variable Info. Please help. Thanks.
[DllImport("myDll.dll")]
public static extern int DLLFunction(out int Num, StringBuilder Info);
int Num;
string Info = new StringBuilder(80);
DLLFunction(out Num, Info);
string results = Info.ToString();
HTH,
Mythran
Well, if he compiled it as it was, he would get a compile-time error since Num has not been initialize, which is why I set it to "out" instead...but I should have noted that :)
Mythran
.
- References:
- Re: Calling dll functions
- From: Mythran
- Re: Calling dll functions
- From: sb
- Re: Calling dll functions
- Prev by Date: Re: StringBuilder vs. String performance
- Next by Date: Re: StringBuilder vs. String performance
- Previous by thread: Re: Calling dll functions
- Next by thread: Re: Calling dll functions
- Index(es):
Relevant Pages
|