473,811 Members | 4,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ struct to Compact Framework struct

1 New Member
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: NotSupportedExc eption.

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

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

Similar topics

1
4977
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 Compact Framework-The .NET Compact Framework is in ROM in all new Pocket PC 2003 devices, and can be installed in RAM in Pocket PC 2000 and Pocket PC 2002 devices. The question is: how? Answers would be greatly appreciated
0
2605
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 PocketPC, works on the laptop with .NET Framework. I was hoping you could help me with answering some questions: 1. Does HTTPS work for the System.Net.WebRequest.Create (sURL), GetRequestStream, System.IO.StreamWriter library calls we are making...
2
2866
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 reinstalled it. I also installed all the QFEs. When I tried to reinstall the release Compact Framework, I get a message that it is already installed and the installation aborted.
1
2527
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 Visual Studio 2003 ships with the functionality for .Net Compact Framework development. But right now I have Visual Studio 2002. Is there anything I can do? (Other than the obvious upgrade to 2003). I've heard some beta version of .Net Compact...
2
2007
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 lot of functionality is identical (or at least similar). As the compact framework is a subset (correct?) of the full framework, we had the idea of building the base functionality as "compact" projects. Thse projects could then be used (or...
15
43587
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 permit the same piece of memory to be referenced as different data types. This is often used to save space and permit a single piece of memory to contain different types of data, typically based on some other flag in the structure. In other cases...
0
1549
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 generate MSIL for use with the Compact Framework used on Windows CE and I cannot see any obvious way to make Visual Studio.Net C++ generate MSIL that uses the
5
3363
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 way of converting a project to have builds for both compact and full. Project properties doesn't seem to help Thanks
3
2628
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 appreciated. Thank you.
0
9724
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.