473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C++ struct to Compact Framework struct

Hi Everybody!

I need help.

I want Import to C# struct written in C++.

C++ code:

Expand|Select|Wrap|Line Numbers
  1. typedef struct 
  2. {
  3. int rssi;
  4. //WCHAR bssid[256];
  5.     char bssid[256];
  6. } mystruct; 
  7.  
  8. extern "C" __declspec(dllexport) void __stdcall GetAdapterStruct(mystruct* st){
  9.  
  10. st[0].rssi=25;
  11. st[1].rssi=300;
  12.  
  13. strcpy(st[0].bssid,"jijijijijijijiuuu");
  14. strcpy(st[1].bssid,"2.huhuhuuh");
  15.  
  16. }
  17.  
  18. C# code:
  19.  
  20.  
  21. public partial class Form1 : Form
  22.     {
  23.         public Form1()
  24.         {
  25.            InitializeComponent();
  26.         }
  27.  
  28.         private void menuItem1_Click(object sender, EventArgs e)
  29.         {
  30.             this.Dispose();
  31.         }
  32.  
  33.         private void button2_Click(object sender, EventArgs e)
  34.         {
  35.             MyStructArray _MyStructArray = new MyStructArray();
  36.             Wrapper.GetAdapterStruct(ref _MyStructArray);
  37.  
  38.             MyStruct neww = (MyStruct)_MyStructArray._MyStruct.GetValue(0);
  39.  
  40.             MessageBox.Show(neww.charac.ToString() + "= charac");
  41.             MessageBox.Show(neww.inte.ToString() + "= inte");
  42.             neww = (MyStruct)_MyStructArray._MyStruct.GetValue(1);
  43.            MessageBox.Show(neww.inte.ToString() + "= inte");
  44.  
  45.  
  46.         }
  47.     }
  48.  
  49.     [StructLayout(LayoutKind.Sequential)]
  50.     public struct MyStruct
  51.     {
  52.         [MarshalAs(UnmanagedType.I4)]
  53.         public int inte;
  54.  
  55.         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
  56.         public string charac; 
  57.  
  58.     }
  59.  
  60.     [StructLayout(LayoutKind.Sequential)]
  61.     public struct MyStructArray
  62.     {
  63.         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
  64.         public MyStruct[] _MyStruct;
  65.  
  66.     }
  67.  
  68.  
  69.  
  70.     class Wrapper
  71.     {
  72.         Wrapper() { }
  73.  
  74.         DllImport("Resources/DLL/kDll.dll")]
  75.         public static extern void GetAdapterStruct(ref MyStructArray ms);
  76.     }
I tested in PDA emulator 2005. But wrote: NotSupportedException.

Any idea please? Thanks.
Mar 1 '08 #1
0 1011

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: boble | last post by:
Sorry, it's may be off topic ;_((( The following article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppc2k3/ht ml/winmob03.asp states that a.. Microsoft Windows .NET...
0
by: Earle Oxner | last post by:
We are developing an application on PocketPC2002 platform and we are trying to make webservice calls using HTTPS. HTTP works fine but HTTPS does not work. The same code which doesn't work on...
2
by: Duncan | last post by:
I am using the evaluation version of CE.NET 4.1. I had also installed the release version of the Compact Framework. I uninstalled the CE.NET 4.1, and then realized I needed it again and...
1
by: Asad Khan | last post by:
Hi, I have Visual Studio 2002 Enterprise Architecture Edition. I was wondering if anyone has any information on how I can develop applications for .Net Compact Framework using this IDE. I've heard...
2
by: Hans Kesting | last post by:
Is it possible to mix code meant for the CompactFramework and code meant for the standard framework? We are trying to make PDA and light-weight "laptop" versions of one application. This means a...
15
by: Ken Allen | last post by:
I have some code from C/C++ that I am attempting to port to C#. I have come across an interesting problem that is quite common in complex C/C++ code: the us of UNION in structure definitions to...
0
by: Roland Rosier | last post by:
Hello, I am trying to understand Managed C++ and the .Net Framework, and as far as I can tell, you add a /CLR option to the compiler to make it generate MSIL from C++. However, I need to...
5
by: bob | last post by:
Hi Using 2003 - targeting the compact framework (c#), but would like to do most development using the full.net (manually leaving out stuff not in the compact framework). Q. Trying to find a...
3
by: Greg | last post by:
Hello all, I am looking to download an image from a website from within a compact framework pda app. I have tried everything I could find and thus I turn to you. Any help or suggestions would be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.