Link to home
Start Free TrialLog in
Avatar of prashanth_gurijala
prashanth_gurijala

asked on

Integrating vb.net and c#

hi,
i have this methods in vb.net and i want to access them from c#
i am posting both of them...
can any one help me out

[[[[vb.net]]]]---------------------------------------------------------------------------------------------

Imports System.Management
Public Function GetSignalStrength() As String
        On Error GoTo oops

        Dim query As ManagementObjectSearcher
        Dim Qc As ManagementObjectCollection
        Dim Oq As ObjectQuery
        Dim Ms As ManagementScope
        Dim Co As ConnectionOptions
        Dim Mo As ManagementObject
        Dim outp As String
        Dim ssid As String
        Co = New ConnectionOptions
        Ms = New ManagementScope("root\wmi")
        Oq = New ObjectQuery("SELECT * FROM MSNdis_80211_ReceivedSignalStrength Where active=true")
        query = New ManagementObjectSearcher(Ms, Oq)
        Qc = query.Get
        outp = ""
        For Each Mo In query.Get
            outp = outp & Mo("Ndis80211ReceivedSignalStrength") & " "
        Next
        Return Trim(outp)
        Exit Function
oops:
        Return Err.Description
    End Function

[[[[c# code]]]]--------------------------------------------------------------------------------------------------------
using System;
using System.Net;
using System.Net.Sockets;

namespace UdpEchoServer
{
    class App
    {
        private const int ServerPortNumber = 9696;

            [STAThread]
        static void Main(string[] args)
        {
            try {
                Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                        EndPoint localEP = new IPEndPoint(IPAddress.Any, ServerPortNumber);
                EndPoint remoteEP = new IPEndPoint(IPAddress.None, ServerPortNumber);
                udpSocket.Bind(localEP);

                byte [] receiveBuffer = new byte [512];
                try
                        {
                    while (true)
                              {
                        int receivedSize = udpSocket.ReceiveFrom(receiveBuffer, ref remoteEP);
                                                                                                             ***********//// i want to access the wireless signal strength method here
                        udpSocket.SendTo(receiveBuffer, receivedSize, SocketFlags.None, remoteEP);
                    }
                }
                        finally
                        {
                    udpSocket.Close();
                }
                        }
                        catch (SocketException se)
                        {
                              Console.WriteLine(se.ToString());
                        }
        }
    }
}
SOLUTION
Avatar of volking
volking

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial