Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling and Disabling Local Area Connection from inside .NET

I'm working with an Ethernet board that is installed with an IP address of 10.10.10.2. It is named "Local Area Connection 2" under my LAN settings in Network Neighborhood. Is it possible to use NI tools from inside .NET to actually do the equivalent of right clicking on “Local Area Connection 2” and selecting “Disable” and then right clicking on “Local Area Connection 2” and selecting “Enable”? When I do this manually the connection resets exactly the way I want. I’m not handling the socket assignment correctly but I was looking for a work around since I’m only testing the hardware and not writing the firmware.

I don’t know if what I’m asking for here is possible. I’d like to send a VISA command to disable the port but then how do you send another command to enable it when it’s disabled? It doesn’t sound very promising does it. I was hoping that there might be some way of controlling a connection this way or at least getting the connection to behave like it was just manually disabled/enabled. Any/all advice is welcome and appreciated.

Thanks,

Grant
Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 1 of 4
(4,195 Views)
Grant,

I am not aware of any VISA functions that will do what you described. VISA simply makes calls to the Operating System, and the Operating system actually handles the communication. This makes me think that if a function like you described does exist it would be in the Windows API.

Shawn B.
National Instruments
Use NI products on Linux? Come join the NI Linux Users Community
0 Kudos
Message 2 of 4
(4,176 Views)
I found this code snippet here which shows how you could set this up in C++, so I wrapped that code into a managed assembly that you can call from a .net application.

This is all Win32 Shell Intefaces, so you will need to refer to the MSDN for more information about the functions. I have attached the assembly and a test C# app.

I'm not sure if anything like this is built into the .NET framework. But this does seem to work. I hope this helps. This is for XP and 2K only.
Bilal Durrani
NI
0 Kudos
Message 3 of 4
(4,154 Views)
Thanks a ton Bilal. It works great.
Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 4 of 4
(4,130 Views)