Hi, I need to pass a relativly complicated struct into a dll calling a CORBA Service which has to be written in vc6.0 and it has to contain many elements which are necessary to create an input for a service. Unfortunately I can see only the first array element, other are ignored. Here an example of c# code: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MyStrStruct3 { public string FirstName; public string FamilyName; public int size; } [DllImport(@"C:\Projects\CorbaLib60\Debug\CorbaLib.dll")] private static extern int TestMe(ref MyStrStruct3[] pstr); MyStrStruct3[] Names = new MyStrStruct3[2]; Names[0].FamilyName = "Konieczny"; Names[0].FirstName = "Marek"; Names[0].size = 3; Names[1].FamilyName = "OtherName"; Names[1].FirstName = "OtherFirst"; Names[1].size = 2; int miki1 = TestMe(ref Names);
C++ code look like this: typedef struct _MyStruct2 { char* FirstName; char* FamilyName; UINT size; } MyStruct2; int TestMe(MyStruct2* pStruct[]) { int Size = 2; for (int i=0; isize; char* miki = pStruct[i]->FamilyName; char* miki1 = pStruct[i]->FirstName; } return 42; }
I define export : __declspec(dllexport) int TestMe(MyStruct2* pStruct[2]);
It works, but only for first element. I also have tried to pass it as [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MyStrStruct4 { public MyStrStruct3[] Names; public int size; }
but it doesn't work and raise an exception. Marek
Marek Konieczny
Posts
-
Passing an array of structs from c# to unmanaged c++ dll -
Passing an array of structs from c# to unmanaged c++ dllHi, I need to pass a relativly complicated struct into a dll calling a CORBA Service which has to be written in vc6.0 and it has to contain many elements which are necessary to create an input for a service. Unfortunately I can see only the first array element, other are ignored. Here an example of c# code:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MyStrStruct3 { public string FirstName; public string FamilyName; public int size; } [DllImport(@"C:\Projects\CorbaLib60\Debug\CorbaLib.dll")] private static extern int TestMe(ref MyStrStruct3[] pstr); MyStrStruct3[] Names = new MyStrStruct3[2]; Names[0].FamilyName = "Konieczny"; Names[0].FirstName = "Marek"; Names[0].size = 3; Names[1].FamilyName = "OtherName"; Names[1].FirstName = "OtherFirst"; Names[1].size = 2; int miki1 = TestMe(ref Names);
C++ code look like this:typedef struct _MyStruct2 { char* FirstName; char* FamilyName; UINT size; } MyStruct2; int TestMe(MyStruct2* pStruct[]) { int Size = 2; for (int i=0; isize; char* miki = pStruct[i]->FamilyName; char* miki1 = pStruct[i]->FirstName; } return 42; }
I define export :__declspec(dllexport) int TestMe(MyStruct2* pStruct[2]);
It works, but only for first element. Marek -
Downloading ImageThanks for help, but I actually do not want any user interaction, except for specifying name for data. When I make response.redirect("myzipfile.zip") and point to a zip file, the dialog for saving data locally appears. This ist what I want to see when I redirect to an image file, istead of displaying it. Marek
-
Downloading ImageI am generating a high resoulution image on the web server, which should be afterward downloaded onto users machine without displaying it in the browser and requiring user to make a right click and choosing "Save image as..." What would be the best aproach to do it? Sincerely Marek
-
Repeater DataHi Turning Strict on was not an option, but second proposal was exactly I was looking for. Thanks a lot Marek
-
Repeater DataI have placed a DropDownList within a Repeater and I am having troubles to set correct value to DropDownlist. I tried following code
Private Sub rptDep_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptDep.ItemDataBound Dim myList As DropDownList = CType(e.Item.FindControl("cboProjectRule"), DropDownList) ' Dim dr As DataRow = CType(e.Item.DataItem.Row, DataRow) ' some other code hier end sub
but commented line does not work because of option Strict = On. Any Suggestions? Marek -
Pentium M vs. IVHi Pete Both processor are designed for use in notebooks. So far I know M supports 533/400 MHz Front Side Bus, while 4-M only 400MHz. M has bigger cache - 1 or 2 MB, P4-M has 512 KB. Your forgot about display and support. I would consider anything with higher resolution then 1024 x 786. And if you are going to seriously work on it, you probably would not like to sent it for two or more weeks for repairing. 512 MB is an absolutely minimum. If you are going to install VS 2005 and any kind of SQL Server on it, 1 GB is higly recommended - but usually it is cheaper to buy this extra memory later then order it with notebook. Processor is one of the least important factors in this list - of course it depends what kind of software you are going to develop - but for standard businness applications I would put it on place before wireless card, which has really not influence on developing software. But it is nice to have. ;-) Marek
-
Save DataTable to dbfHi You can try to use OLE DB Provider for Visual Foxpro. http://www.microsoft.com/downloads/details.aspx?FamilyId=E1A87D8F-2D58-491F-A0FA-95A3289C5FD4&displaylang=en VFP native data format are dbf tables Greeting Marek
-
Get all TextBoxes on the PageThanks, with parentControl.Controls it works. Sorry, there was a little bit late here and my brain did function very slowly ;-) Now I will try to describe my problem: I was wondering if there is possible to define a string which has a control name as it contents eg. fName = "TextBox1" and then read or change the content of this control, e.g Textbox1.Text using fName variable. I hope now I expressed myself clearer :) Marek
-
Get all TextBoxes on the PageThis would be fine if not a compiler error "foreach statement cannot operate on variables of type 'System.Web.UI.Control' because 'System.Web.UI.Control' does not contain a definition for 'GetEnumerator', or it is inaccessible" Nevertheless my problem is little bit different. I want to generate an sql statement using private string MakeQuery() { string fName, fContents; for (int i = 1; i<= 5; i++) { fName = " ,Desc" + i.ToString(); //fContents = ?????; } }
-
Get all TextBoxes on the PageHi I would like to access contents controls on a web page using variables instead of calling them directly and actually don't know how to do it. To make it clear: I have a some TextBox controls with ID 1 to 10 and want to access them in a loop and read their contents Thanks
-
ADO + SQL + FOXPRO Question/problemHi It is probably because VFP Drivers are not included in MDAC 2.6 and above. You can download this drivers from Microsoft Visual FoxPro page. Here is the link http://msdn.microsoft.com/vfoxpro/downloads/addons/odbc.asp Greeting Marek
-
i uninstalled MSDE and toasted the service mgr...MSDE is a limited Version of SQL Server and it is actually the same service called MSSQLSERVER Check in Services Control Panel if there is a MSSQLSERVER service running and if it shows to correct path. It can be that you will have to reinstall SQL Server Marek
-
editing dBase filesHi Excel has limitation of 65000 rows and for this reason it is not best tool for this job. You can try with Access. There is an ODBC Driver for dBase, or you can also use Visual FoxPro driver. Other possibility is purchase of Visual FoxPro - it can read dBase files as native format. Beware of 2 GB Limitation of this format. Sincerely Marek