Click here to Skip to main content
15,921,250 members
Home / Discussions / C#
   

C#

 
GeneralRe: RCW question when returning a string Pin
Heath Stewart22-May-04 3:49
protectorHeath Stewart22-May-04 3:49 
GeneralRe: RCW question when returning a string Pin
Nish Nishant22-May-04 3:58
sitebuilderNish Nishant22-May-04 3:58 
GeneralRe: RCW question when returning a string Pin
Heath Stewart22-May-04 4:07
protectorHeath Stewart22-May-04 4:07 
GeneralRe: RCW question when returning a string Pin
Nish Nishant22-May-04 4:17
sitebuilderNish Nishant22-May-04 4:17 
GeneralRe: RCW question when returning a string Pin
Heath Stewart22-May-04 4:18
protectorHeath Stewart22-May-04 4:18 
Generallistbox control in C# Pin
HowRU21-May-04 22:22
HowRU21-May-04 22:22 
GeneralRe: listbox control in C# Pin
Heath Stewart22-May-04 4:52
protectorHeath Stewart22-May-04 4:52 
GeneralPassing a Class to an Unmanaged function as parameter Pin
shajuMathew21-May-04 20:49
shajuMathew21-May-04 20:49 
Hai all...

I was trying to pass a class to an Unmanaged function. The class has a member of type, of the same class. Is it possible to pass a Managed class(Class having a member of it's own type) to an Unmanaged function.

Thanks in advanceRose | [Rose]

Below is what i did...

This is the class i created to pass into an Unmanaged function as parameter

[StructLayout(LayoutKind.Explicit )]
public class MyWindow
{
[FieldOffset (0)]
public String className;
[FieldOffset (16)]
public String caption;
[FieldOffset (32)]
public MyWindow child ;

}
But if i remove the class member 'child' from the class it works well.

Unmanaged function Decleration

[DllImport("user32")]
public static extern bool EnumChildWindows(int hwndParent, EnumChildDelegare lpEnumFunc, MyWindow lParam) ;


This is the way how i call the unmanaged function

MyWindow m = new MyWindow ();
Win32Calls.EnumChildWindows (winHandle,w.enumChildDlgate ,m);

And i am getting this error.

An unhandled exception of type 'System.TypeLoadException' occurred in CSRecorder.exe
Additional information: Can not marshal field child of type CSRecorder.MyWindow: This type can not be marshaled as a structure field.


Shaju Mathew
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Heath Stewart22-May-04 4:17
protectorHeath Stewart22-May-04 4:17 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
shajuMathew26-May-04 1:32
shajuMathew26-May-04 1:32 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Heath Stewart26-May-04 3:23
protectorHeath Stewart26-May-04 3:23 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
Member 93002222-May-04 9:18
Member 93002222-May-04 9:18 
GeneralRe: Passing a Class to an Unmanaged function as parameter Pin
shajuMathew26-May-04 1:35
shajuMathew26-May-04 1:35 
QuestionHow to use a DirectShow filter in C# ? Pin
ro_angel_bv21-May-04 20:11
ro_angel_bv21-May-04 20:11 
AnswerRe: How to use a DirectShow filter in C# ? Pin
Heath Stewart22-May-04 4:00
protectorHeath Stewart22-May-04 4:00 
GeneralRe: How to use a DirectShow filter in C# ? Pin
ro_angel_bv22-May-04 9:21
ro_angel_bv22-May-04 9:21 
GeneralRe: How to use a DirectShow filter in C# ? Pin
Heath Stewart23-May-04 3:31
protectorHeath Stewart23-May-04 3:31 
GeneralRe: How to use a DirectShow filter in C# ? Pin
mjKPL1-Sep-10 5:55
mjKPL1-Sep-10 5:55 
GeneralFile Compression Pin
demasoni.com21-May-04 19:34
demasoni.com21-May-04 19:34 
GeneralRe: File Compression Pin
David M. Kean22-May-04 0:35
David M. Kean22-May-04 0:35 
GeneralRe: File Compression Pin
demasoni.com22-May-04 12:48
demasoni.com22-May-04 12:48 
GeneralSetup with InstallShield Pin
quocbao21-May-04 16:34
quocbao21-May-04 16:34 
GeneralRe: Setup with InstallShield Pin
Heath Stewart22-May-04 2:38
protectorHeath Stewart22-May-04 2:38 
GeneralCalling a function in another window. Pin
Bojan Rajkovic21-May-04 16:13
Bojan Rajkovic21-May-04 16:13 
GeneralRe: Calling a function in another window. Pin
Dimitris Iliopoulos22-May-04 0:06
Dimitris Iliopoulos22-May-04 0:06 

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.