Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: what is method group? Pin
George_George11-Sep-08 15:45
George_George11-Sep-08 15:45 
QuestionQuerying what kind of mail server is active on a machine Pin
Matt Fishbeck10-Sep-08 0:29
Matt Fishbeck10-Sep-08 0:29 
AnswerRe: Querying what kind of mail server is active on a machine Pin
leppie10-Sep-08 0:34
leppie10-Sep-08 0:34 
GeneralRe: Querying what kind of mail server is active on a machine Pin
Matt Fishbeck10-Sep-08 0:37
Matt Fishbeck10-Sep-08 0:37 
GeneralRe: Querying what kind of mail server is active on a machine Pin
leppie10-Sep-08 0:39
leppie10-Sep-08 0:39 
GeneralRe: Querying what kind of mail server is active on a machine Pin
leppie10-Sep-08 0:39
leppie10-Sep-08 0:39 
GeneralRe: Querying what kind of mail server is active on a machine Pin
Matt Fishbeck10-Sep-08 0:56
Matt Fishbeck10-Sep-08 0:56 
QuestionHow can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 0:29
verence33310-Sep-08 0:29 
Hello!

I'm starting to use C#, and I feel lost right now.

I've got a "somestruct.h" file with a C++ struct:

struct SOMESTRUCT
{
TCHAR Field1[100];
int Field2;
double Field3;
};

And, in a C++ class, I have a function that returns a SOMESTRUCT:

SOMESTRUCT someFunction();

Now I have a C# app which will call the C++ function. I have the C++ code in a DLL and I try to import the DLL so I can call that function:

[DllImport("myDLL.dll", CharSet = CharSet.Auto)]
static extern SOMESTRUCT someFunction();

Problem is: my C# app doesn't know the SOMESTRUCT struct. I can't import "somestruct.h" in C# and I really don't know how could I use that function.

I think maybe I could make a managed version of the struct SOMESTRUCT, but I don't know how to transform a fixed-size char array (Field1). If I transform it to a String it doesn't work properly.

I have also read that I could make a wrapper of the struct to get it work from C#, but I just cannot find an easy-to-understand, newbie-suitable, complete example of how to do it.

Please, could somebody help me? Smile | :)
AnswerRe: How can I use a C++ struct from a C# app? Pin
leppie10-Sep-08 0:31
leppie10-Sep-08 0:31 
GeneralRe: How can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 0:47
verence33310-Sep-08 0:47 
GeneralRe: How can I use a C++ struct from a C# app? Pin
leppie10-Sep-08 0:59
leppie10-Sep-08 0:59 
GeneralRe: How can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 1:14
verence33310-Sep-08 1:14 
GeneralRe: How can I use a C++ struct from a C# app? Pin
leppie10-Sep-08 1:19
leppie10-Sep-08 1:19 
GeneralRe: How can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 1:52
verence33310-Sep-08 1:52 
AnswerRe: How can I use a C++ struct from a C# app? Pin
Gideon Engelberth10-Sep-08 3:28
Gideon Engelberth10-Sep-08 3:28 
GeneralRe: How can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 3:45
verence33310-Sep-08 3:45 
GeneralRe: How can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 21:05
verence33310-Sep-08 21:05 
AnswerRe: How can I use a C++ struct from a C# app? Pin
Alan Balkany10-Sep-08 3:57
Alan Balkany10-Sep-08 3:57 
GeneralRe: How can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 4:20
verence33310-Sep-08 4:20 
GeneralRe: How can I use a C++ struct from a C# app? Pin
Alan Balkany10-Sep-08 4:43
Alan Balkany10-Sep-08 4:43 
GeneralRe: How can I use a C++ struct from a C# app? Pin
verence33310-Sep-08 5:27
verence33310-Sep-08 5:27 
QuestionWhat's difference between a DLL file & an assembly file ? Pin
Mohammad Dayyan10-Sep-08 0:14
Mohammad Dayyan10-Sep-08 0:14 
AnswerRe: What's difference between a DLL file & an assembly file ? Pin
blackjack215010-Sep-08 0:25
blackjack215010-Sep-08 0:25 
GeneralRe: What's difference between a DLL file & an assembly file ? Pin
Mohammad Dayyan10-Sep-08 0:30
Mohammad Dayyan10-Sep-08 0:30 
GeneralRe: What's difference between a DLL file & an assembly file ? Pin
leppie10-Sep-08 0:32
leppie10-Sep-08 0:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.