473,406 Members | 2,816 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,406 software developers and data experts.

Managed C++ - Question

Hi everyone,

I'm relatively new to managed c++ (though experienced in unmanaged c++), but
I just can't figure out how to do the following c-sharp lines in managed c++
(studio 2003). Can anyone enlighten me, please?

Following is a simple C-Sharp-Source for reading out wireless lan
signal-strength:

using System;
using System.Management;
class App
{
public static void Main()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
@"root\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("{0}",mo["Ndis80211ReceivedSignalStrength"]);
}
}
}

Thanks in advance
Rainer Sinsch
Nov 17 '05 #1
4 4673
You can't mix C# in managed C++. You can either recode it as managed C++ (no
foreach), or create a new C# project and then the code will compile. You will
be able to call the C# code from managed C++, if needed.

Rainer Sinsch wrote:

Hi everyone,

I'm relatively new to managed c++ (though experienced in unmanaged c++), but
I just can't figure out how to do the following c-sharp lines in managed c++
(studio 2003). Can anyone enlighten me, please?

Following is a simple C-Sharp-Source for reading out wireless lan
signal-strength:

using System;
using System.Management;
class App
{
public static void Main()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
@"root\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("{0}",mo["Ndis80211ReceivedSignalStrength"]);
}
}
}

Thanks in advance
Rainer Sinsch

Nov 17 '05 #2

"Rainer Sinsch" <no****@please.com> wrote in message
news:c1**********@mail1.sbs.de...
Hi everyone,

I'm relatively new to managed c++ (though experienced in unmanaged c++), but I just can't figure out how to do the following c-sharp lines in managed c++ (studio 2003). Can anyone enlighten me, please?

Following is a simple C-Sharp-Source for reading out wireless lan
signal-strength:

using System;
using System.Management;
class App
{
public static void Main()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
@"root\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("{0}",mo["Ndis80211ReceivedSignalStrength"]);
}
}
}


ManagementObjectSearcher.Get returns ManagementObjectCollection.
ManagementObjectCollection.GetEnumerator returns ManagementObjectEnumerator.
and then while(ManagementObjectEnumerator.MoveNext())
ManagementObjectEnumerator.Current returns ManagementBaseObject, of which
ManagementObject is derived.
Nov 17 '05 #3
Thanks Michiel - it worked just fine.

Just in case anyone else wants to know, here's the source for reading out
the current signal strength on the last wireless lan adapter installed (in
case you have more than 1). Anyway, the source can be easily changed.

int GetSignalStrength()
{
ManagementObjectSearcher *searcher = new ManagementObjectSearcher(
"root\\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");

ManagementObjectCollection *queryCollection = searcher->Get();

ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum =
queryCollection->GetEnumerator();
while (queryEnum->MoveNext());

ManagementBaseObject* object = queryEnum->get_Current();
Object* signalStrength =
object->GetPropertyValue(L"Ndis80211ReceivedSignalStrengt h");
return (Convert::ToInt32(signalStrength->ToString()));
}

Best regards
rainer

"Michiel" <mi*********@RECLAMEpayvision.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

"Rainer Sinsch" <no****@please.com> wrote in message
news:c1**********@mail1.sbs.de...
Hi everyone,

I'm relatively new to managed c++ (though experienced in unmanaged c++), but
I just can't figure out how to do the following c-sharp lines in managed

c++
(studio 2003). Can anyone enlighten me, please?

Following is a simple C-Sharp-Source for reading out wireless lan
signal-strength:

using System;
using System.Management;
class App
{
public static void Main()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
@"root\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("{0}",mo["Ndis80211ReceivedSignalStrength"]);
}
}
}


ManagementObjectSearcher.Get returns ManagementObjectCollection.
ManagementObjectCollection.GetEnumerator returns

ManagementObjectEnumerator. and then while(ManagementObjectEnumerator.MoveNext())
ManagementObjectEnumerator.Current returns ManagementBaseObject, of which
ManagementObject is derived.

Nov 17 '05 #4
Thanks Michiel - it worked just fine.

Just in case anyone else wants to know, here's the source for reading out
the current signal strength on the last wireless lan adapter installed (in
case you have more than 1). Anyway, the source can be easily changed.

int GetSignalStrength()
{
ManagementObjectSearcher *searcher = new ManagementObjectSearcher(
"root\\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");

ManagementObjectCollection *queryCollection = searcher->Get();

ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum =
queryCollection->GetEnumerator();
while (queryEnum->MoveNext());

ManagementBaseObject* object = queryEnum->get_Current();
Object* signalStrength =
object->GetPropertyValue(L"Ndis80211ReceivedSignalStrengt h");
return (Convert::ToInt32(signalStrength->ToString()));
}

Best regards
rainer

"Michiel" <mi*********@RECLAMEpayvision.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

"Rainer Sinsch" <no****@please.com> wrote in message
news:c1**********@mail1.sbs.de...
Hi everyone,

I'm relatively new to managed c++ (though experienced in unmanaged c++), but
I just can't figure out how to do the following c-sharp lines in managed

c++
(studio 2003). Can anyone enlighten me, please?

Following is a simple C-Sharp-Source for reading out wireless lan
signal-strength:

using System;
using System.Management;
class App
{
public static void Main()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
@"root\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("{0}",mo["Ndis80211ReceivedSignalStrength"]);
}
}
}


ManagementObjectSearcher.Get returns ManagementObjectCollection.
ManagementObjectCollection.GetEnumerator returns

ManagementObjectEnumerator. and then while(ManagementObjectEnumerator.MoveNext())
ManagementObjectEnumerator.Current returns ManagementBaseObject, of which
ManagementObject is derived.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eric Twietmeyer | last post by:
Hello, I'm starting to investigate cs, managed c++ and interoperating with a very large unmanaged code base. We are going to use Windows Forms (written in cs) to replace our old fashioned GUI. ...
12
by: Bret Pehrson | last post by:
Suppose the following: // Unmanaged code class UnmanagedException /* not visible outside of unmanaged code */ { }; void DoSomething() /* visible (exported) to managed code */ { throw new...
4
by: repstat | last post by:
Hi I have a project which is going to be doing some string manipulation which needs to be pretty fast. The user interface is going to be written in C#. I am going to write the string handling...
2
by: bor_kev | last post by:
Hi, First of all, i want to use the new managed class syntax and STL.NET under Microsoft Visual (C++) Studio 2005 Beta. I read in a Microsoft...
3
by: Thorsten | last post by:
HI I'm a C# developer and unfortunately I have to write now some code in managed and unmanaged C++. In this area I'm Newbie and therefore please forgive me if this is a really simple...
5
by: achutha.sridhar | last post by:
I've a pretty basic question on managed code. I read through couple of.net documentation, and reached a state where I know that managed code would be run by the .Net run time and it has so and so...
5
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I have a class that is writen in unmanaged pure native C++. This class files (h and cpp) are inserted to a managed C++ (VC++ 2005, C++/CLI) DLL compoenet. This DLL compoenet is used in a C#...
8
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx...
9
by: =?Utf-8?B?RWR3YXJkUw==?= | last post by:
I would greatly appreciate some help on passing managed object into unmanaged code. I need to pass a reference (address of) of a managed class into unmanaged code (written by a thrid party). The...
2
by: Bob Altman | last post by:
Hi all, We have a native class modeled after the System::Exception class, and all exceptions that we throw derive from this class. For now this class is quite simple: just Description and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.