Click here to Skip to main content
15,902,635 members
Home / Discussions / C#
   

C#

 
AnswerRe: accesing form from another Class Pin
led mike9-May-06 8:45
led mike9-May-06 8:45 
QuestionDllNotFoundException Pin
Larsenal9-May-06 7:40
Larsenal9-May-06 7:40 
AnswerRe: DllNotFoundException Pin
Phillip M. Hoff9-May-06 19:43
Phillip M. Hoff9-May-06 19:43 
QuestionCreating Application's Option Window Pin
student_rhr9-May-06 6:22
student_rhr9-May-06 6:22 
AnswerRe: Creating Application's Option Window Pin
Josh Smith9-May-06 7:09
Josh Smith9-May-06 7:09 
GeneralRe: Creating Application's Option Window Pin
student_rhr9-May-06 7:37
student_rhr9-May-06 7:37 
QuestionIncluding traditional C code in a C# project Pin
Kenny O'Dell9-May-06 5:44
Kenny O'Dell9-May-06 5:44 
AnswerRe: Including traditional C code in a C# project Pin
Andy Moore9-May-06 6:58
Andy Moore9-May-06 6:58 
To use your C code in a C# project, you will have to compile your C code to a dll and export those functions you want to call from your C# code. Also, any structures and data types will have to be redefined in your C# code. I would suggest reading up on P/Invoke since this is what you will have to do. An example is as follows:

/*In my C code*/
typedef struct MyStruct<br />
{<br />
   int x;<br />
   int y;<br />
   char buf[ 80 ];<br />
}<br />
<br />
void Foo( MyStruct* pStruct );<br />

Compile this to, say, MyDll.dll.

Your C# code would do something like this:
[
LayoutKind(LayoutKind.Sequential)]<br />
public struct MyStruct<br />
{<br />
   public int x;<br />
   public int y;<br />
   [MarshalAs(ByValTStr), SizeConst = 80]<br />
   public string buf;<br />
}<br />
[DllImport("MyDll.dll")]<br />
public static extern void Foo( ref MyStruct );


I hope this helps get you started.


Deus caritas est
GeneralRe: Including traditional C code in a C# project Pin
Kenny O'Dell9-May-06 10:32
Kenny O'Dell9-May-06 10:32 
GeneralRe: Including traditional C code in a C# project Pin
Andy Moore9-May-06 10:39
Andy Moore9-May-06 10:39 
QuestionHelp with Random integers Array Pin
eric_tran9-May-06 5:35
eric_tran9-May-06 5:35 
AnswerRe: Help with Random integers Array Pin
J4amieC9-May-06 5:38
J4amieC9-May-06 5:38 
AnswerRe: Help with Random integers Array Pin
conemajstor9-May-06 5:42
conemajstor9-May-06 5:42 
AnswerRe: Help with Random integers Array Pin
eric_tran9-May-06 5:50
eric_tran9-May-06 5:50 
GeneralRe: Help with Random integers Array Pin
conemajstor9-May-06 5:58
conemajstor9-May-06 5:58 
GeneralRe: Help with Random integers Array Pin
eric_tran9-May-06 6:12
eric_tran9-May-06 6:12 
AnswerRe: Help with Random integers Array Pin
Robert Rohde9-May-06 6:21
Robert Rohde9-May-06 6:21 
GeneralRe: Help with Random integers Array Pin
eric_tran9-May-06 6:30
eric_tran9-May-06 6:30 
GeneralRe: Help with Random integers Array Pin
Wjousts9-May-06 7:14
Wjousts9-May-06 7:14 
GeneralRe: Help with Random integers Array Pin
Robert Rohde9-May-06 8:00
Robert Rohde9-May-06 8:00 
GeneralRe: Help with Random integers Array Pin
Wjousts9-May-06 8:08
Wjousts9-May-06 8:08 
GeneralRe: Help with Random integers Array Pin
Robert Rohde9-May-06 8:41
Robert Rohde9-May-06 8:41 
GeneralRe: Help with Random integers Array Pin
Rob Philpott10-May-06 0:37
Rob Philpott10-May-06 0:37 
AnswerRe: Help with Random integers Array Pin
Wjousts9-May-06 7:09
Wjousts9-May-06 7:09 
QuestionHow to change the color of scroll bar in c# desktop Application ? Pin
Jax_qqq9-May-06 5:22
Jax_qqq9-May-06 5:22 

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.