psycopk Posted October 27, 2010 Report Posted October 27, 2010 dude chinna help...i need to call a c++ function from c# code.generally we use pinvoke to call the functions form c++the issue here is the function takes a struct variable as a parameter...how do i call that function?? any references or suggestion??
psycopk Posted October 27, 2010 Author Report Posted October 27, 2010 [quote author=sweetmagic1000 link=topic=113559.msg1210854#msg1210854 date=1288217896]You can use DllImport[/quote]what about the struct parameter to the fuction??do you have any samples?
sweetmagic1000 Posted October 27, 2010 Report Posted October 27, 2010 using System;using System.Runtime.InteropServices;struct Point{ public int x; public int y; public override string ToString() { return(String.Format("({0}, {1})", x, y)); }}struct Rect{ public int left; public int top; public int right; public int bottom; public override string ToString() { return(String.Format("({0}, {1})\n ({2}, {3})", left, top, right, bottom)); }}struct WindowPlacement{ public uint length; public uint flags; public uint showCmd; public Point minPosition; public Point maxPosition; public Rect normalPosition; public override string ToString() { return(String.Format("min, max, normal:\n{0}\n{1}\n{2}", minPosition, maxPosition, normalPosition)); }}public class CallingaFunctionwithaStructureParameterWindow{ [DllImport("user32")] static extern int GetForegroundWindow(); [DllImport("user32")] static extern bool GetWindowPlacement(int handle, ref WindowPlacement wp); public static void Main() { int window = GetForegroundWindow(); WindowPlacement wp = new WindowPlacement(); wp.length = (uint) Marshal.SizeOf(wp); bool result = GetWindowPlacement(window, ref wp); if (result) { Console.WriteLine(wp); } } } See this it may help u...iam not sure
psycopk Posted October 27, 2010 Author Report Posted October 27, 2010 normal ga aaite paina method ee use chese vadini... ee struct parameter valla problem vastundi....
sweetmagic1000 Posted October 27, 2010 Report Posted October 27, 2010 Does it help u??Aithe okay..... :0012391:
Recommended Posts