And by this question I mean the user assigned names windows lets you type in like: "My home network" "Basement" "Garage" not the ssid (though I would also like to read that one for the wifi connections)
and I especially want to read the windows security levels that can be chosen for networks: Home/Office/Public
I want to use this information to switch programs on and off automatically when connecting to various networks.
Update:
Thanks to the answer of #Damien_The_Unbeliever I was able to solve my question and find the following information, I hope it will help others too:
Network awareness in windows 7 and vista (MSDN, Unmanaged)
Windows API Code Pack (Microsoft, managed wrapper for
NetworkListManager and others)
How to use the windows NLM API to get notified of new network
connectivity (Codeproject, Managed)
It sounds like you want to use the Network List Manager:
The Microsoft Windows networking environment allows multihomed computers to connect to several networks simultaneously. There may be multiple wireless networks available along with LAN and dial-up connections. Network List Manager identifies available networks and returns network attribute data to the application.
It's a COM API, I'm not aware of a managed equivalent.
Related
This is quite a general question I think but searching online I can't really find that much information. I have an embedded system with a Bluetooth chip that I often use to connect to another embedded device. This connection is very robust and never fails.
However the embedded system can also connect to windows via a virtual serial port. I've written a piece of software to handle the connection using the 32Foot inthehand bluetooth library. It works very consistently on some computers (including my own) but entirely fails or is very flakey on others. One of which is actually an identical system ( same hardware/ same version of windows)
Is there anything I should specifically be looking at in my software to improve reliability accross different computers/ versions of windows when it comes to bluetooth pairing, creation of virtual com ports etc.
Thanks
I write software that runs on Windows and connects to an embedded device via a virtual serial port using the 32Foot library. I've experienced similar issues to you, and from experience the main problems are:
Conflicts between Bluetooth radio on Windows:
Is more than one Bluetooth radio installed/attached? I find that if on a Windows machine there is both an external Bluetooth dongle plugged in, and the internal Bluetooth is switched on, it won't work.
Widcomm/Broadcom and BlueSoleil stacks:
These don't support authentication, and Widcomm/Broadcom don't support setting of a pin. You can check if BluetoothRadio.PrimaryRadio is not null, and if so find out the SoftwareManufacturer of the Bluetooth Radio. If the Manufacturer enum is Bluesoleil, Widcomm or Broadcom then just don't use authentication or SetPin when initializing the BluetoothClient.
Toshiba stack:
This isn't supported at all
Is a supported Bluetooth radio and stack even currently available?:
You can handle a PlatformNotSupportedException which will tell you if there is no currently available supported Bluetooth stack on the machine. This won't let you know if there is more than one radio attached however.
Finally, from experience, internal Bluetooth chips don't always have a good range and interference can really affect the connection. I have had better luck with an external Bluetooth dongle.
Is there an equivalent to Windows' group policies on Windows Mobile?
My goal is to prevent users from being able to change the date or time on a Windows mobile device and instead ideally allow an application to change it instead.
The only tool that may allow to manage such settings is SCMDM (System Center Mobile Device Management: http://en.wikipedia.org/wiki/System_Center_Mobile_Device_Manager).
But you can use a blacklist (http://community.intermec.com/t5/Device-Management/Tips-collection-thread/m-p/2941#M375)
REGEDIT4
;Enable blacklist of applications that should not run
[HKEY_LOCAL_MACHINE\Security\Policies\Shell]
"DisallowRun"=dword:1
;Add entries to blacklist of applications that should not run
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun]
"1"="clock.exe"
You can also disallow access to certain control panel settings using ReDirect="" key
[HKEY_LOCAL_MACHINE\ControlPanel\Clock]
"Redirect"=""
But all this can not replace a good locked down kisok mode application.
I have written several posts about kiosk mode: http://www.hjgode.de/wp/2012/05/29/windows-mobile-kiosk-mode-series-part-2/
I do not know of one. That does not mean it doesn't exist, though.
Our solution here has been to set the device's time every time a database connection to our server is made by forcing all applications to use a global "get open connection" method that first calls SELECT GetDate(); on our SQL Server and sets the Device's date before returning the open connection to the calling method.
Is there an equivalent to Windows' group policies on Windows Mobile?
Windows Mobile is pretty much dead except for the medical community. OT: platform certification is expensive and time consuming (its the FDA equivalent of FIPS 140), so many medical devices still use the older Windows CE core. It could be popular elsewhere, such as Automotive (I don't work with the industry, so I don't know).
Windows Mobile devices do take group policies, so there is no need for an equivalent. Information is still available online and in MSDN. For example, Managing MDM Devices and Configuring Device Group Policy Settings.
Jeff
I have read that pairing is a must before communicating anything over bluetooth, but I want to know,
Can I create an application which would read a text which is
broadcasted by another bluetooth App without being paired.
Because we can see the names of other bluetooth devices around a device. So can't we set our bluetooth radio to a state that it would read any bluetooth boradcasting text message.
Example: there is createInsecureRfcommSocketToServiceRecord() & listenUsingInsecureRfcommWithServiceRecord() in android but aren't there such in C# for windows?
Thanks
My Ultimate Goal :-)
is creating an application running on windows 7 PCs, which create instant Bluetooth network for peer to peer file transfer and chat
Scenario
There is a group of people, each has this app on each computer, one wants to share a file, (may be an eBook, PDF or anything) with the rest. He sets his network "net" ( or any other name) in his app configuration and others also put that same name on each app. Finally each user can see the list of other Bluetooth nodes around them in their apps display, configured to same network name "net". so each can send files to selected nodes in the same network.
Design
Each user only turns on the Bluetooth radio and then enters a desired Network name in then app
Each application on PCs will communicate iteratively to reachable Bluetooth devices, through temporarily created connections (without pairing or user involvement), check their network names and list discoverable PCs with similar network names
Then they will share these lists among each other, so one PC knows the computers in their same network even though they are not in range directly.
Send files from one computer to one or many computers through a path resolved by an algorithm, even send chat texts.
All of this is going to be achieved through simple temporarily Bluetooth connections established between each application time to time, which requires no pairing or authentication, other than the Network Name. ( Because I don't know how to create Piconets using C#, or how to create bluetooth routing protocols.
No other security is implemented.
Please let me know of any other better design or way. Thank you very much for reading the lengthy text. Also include any helpful code which can help me achieve the above.
I make tens of un-paired connections every day... I don't know where this rumour comes from. :-,)
As you note on Android the default was for an authenticated connection -- maybe that's where the rumour started from? Even there, as you note, there are ways to request a 'pairing-not-required' connection e.g. listenUsingInsecureRfcommWithServiceRecord.
So, on the Microsoft stack on Windows one uses Bluetooth (RFCOMM) through a socket (winsock). By default that connection does not require authentication (pairing), nor encryption -- in fact to request auth/enc one must set a socket options. Similarly with Widcomm, you specify when you create the connection what security level you want, and that can be 'None'. Similarly on Bluetopia, similarly on BlueZ on Linux.
So if you use my library 32feet.NET, just use BluetoothClient and BluetoothListener and do not set cli.Authenticate=true etc. :-)
Some code examples
What's your ultimate goal? I've just realised that you were asking about file-transfer in another question... :-)
Anyway for transferring text... On the server-side have code like shown at: http://32feet.codeplex.com/wikipage?title=Bluetooth%20Server-side and on the client like: http://32feet.codeplex.com/wikipage?title=General%20Bluetooth%20Data%20Connections Don't know if you know TextWriter/-Reader sublclasses on .NET, anyway on one side:
....
var wtr = new StreamWriter(peerStream);
wtr.WriteLine("hello");
wtr.Flush();
and on the other:
....
var wtr = new StreamReader(peerStream);
var line = wtr.ReadLine();
MessageBox.Show(line);
There's code in the BluetoothChat which pretty much does something like that.
Alan
I would like to auto-create an ad-hoc wireless network from my laptop.
I use windows XP SP3 and I want to do it using C#.
I have seen some libraries for mobile, but I havent found something regrading PC.
Is there an API to do that ?
Thank you.
Ad-hoc network are usually used in Ubiquitous Computing (smart homes). For a laptop, it depends what you'd like to connect to, as ad-hoc usually work with many devices you control.
May be you mean connecting to whatever network you can, in which case it's more on the OS-level.
If you are willing to setup one machine on the network as a wireless server and forgo Ad Hoc, then the Managed Wifi API on codeplex looks very promising. It is in C# and works on XP SP3 and higher (and a little bit on SP2, fyi). http://managedwifi.codeplex.com/
It uses the Native Wifi API from Microsoft. The Native Wifi API requires you to have a server machine which will hand out private IPs to other devices that connect to the network you create. In Native Wifi you would want StandAlone mode ICS in order to create your network (if you want internet access on your network use full ICS then).
http://msdn.microsoft.com/en-us/library/windows/desktop/dd815252(v=vs.85).aspx
Use the Native Wifi as just a reference though, Managed Wifi API is what you will want for C#.
I'm interested in this too actually. I think this could be useful:
http://msdn.microsoft.com/en-us/library/ms705973(v=vs.85).aspx
Unfortunately, this is only available for Windows 7 and Windows Server 2008 I believe.
I don't know any c#, but if I did, it'd probably make sense. If you find any insight, please contact me, I'd also like to learn how to do this as well.
Currently following is the setup of my wifi connection.
Laptop 1 ------> Wifi Router <------
Laptop 2
There are about 5 laptops which connect to the wifi router to access internet. Network is password protected so anyone with a valid network key can connect and access internet.
I am planning to develop a local website which will be having a list of username and passwords. I will also remove the password of the wifi network so that anyone can connect.
If a connected system tries to access a web page in the internet then redirect them to a Login page (in the local website) and ask them to login. Once successfully logged i,n the mac id should be added to "Allow" list and monitoring starts. Internet should not be available for those who don't have a valid username and password.
I was thinking about developing the application to block/allow internet access though a vb.net/c# application.
I am okay with the website part. What I would like to know is
How I can block/allow internet access through the .net application.
Is it possible in .net or should I be going for an unmanaged code development?
If it is possible where is the best place to start? I have experience in winforms development but not much of network programming.
Will there be any change in my current wifi setup? May be a new webserver/proxy server which will host the website and the windows application?
Sorry about too many questions ;-)
DD-WRT (free firmware) has built in hotspot that already includes many of the features you are looking to build:
http://www.wi-fiplanet.com/tutorials/article.php/3730746
The DD-WRT software runs on the ubiquitous WRT54G router - which you may be using.
Total cost: $0-50 (depending on if you have a WRT54G already)
There are two ways to go about this: You can buy an advanced wireless router that lets you hook up some sort of authentication system, or you can have a separate wired system between the wireless router and its upstream connection (with two network cards). At this point, you should be able to have software on that system to manage the traffic that goes across it (although I don't have direct knowledge of any particular software firewalls that you might be able to use for this)