How to identify if a device (scanner) is local or remote? - c#

Context:
I have a C# application that works with a scanner, on a Windows 10 environment.
In some situation, users would, from their local computer, connect to a remote computer that is running the application.
The application shows a list of scanners that are available, both local and remote.
I need the application to be able to identify whether a scanner is local (connected to the computer the user is on) or remote (connected to the computer on which the application is running).
What I have tried:
Using the DeviceManager object from the WIA library, I am able to get a list of properties (DeviceInfo.Properties) from each device connected to the computer.
One property, PnP ID String, always displays "&rev" for remote scanners.
Example of PnP ID String for a local scanner:
For a remote scanner:
This behavior has been observed with several scanners from different brands (namely Fujitsu, HP).
The "tsusb-session" string found for the remote scanner looked intersting in the first place but is absent when testing with HP scanners.
Also, one of the properties that is recovered is Remote Device ID, but it is always displayed blank.
Is the "&rev" thing a reliable way to identify a remote device ?
If not, is there an accurate way to do it ?

Related

Accessing the database on the server with a windows service

I wrote a windows service that detects usb drives plugged into the computer.I can get data such as computer IP address, transaction date, usb name, plugged and unplugged warning.My goal is to monitor usb movements on computers in the local network.For this I need to maintain a database on a server in the local network.I want this database to be updated when usb is plugged into any computer.How can I do this in a local network specific? What are the steps to follow?I am open to all suggestions.

How to force windows mobile to roam between different WiFi access points just like android and PC

I have a windows mobile 6.5 professional device that has PWC for configuring its WiFi. There is several access points with different SSIDs in my network. This device can connect manually to all of them one by one. I mean the device has saved configuration for all Access points and I can disconnect from one of them and then connect to other one.
I know Roaming Trigger can force WM to Roam between APs with similar SSID and encryption types according to AP quality. But the device can't roam when SSID or encryption type changes. I had another device with Summit for configuring its WiFi that could connect to any saved network just like android and laptop.
Now the question is:
How can I force Windows Mobile 6.5 device to switch between purely different access points just like android and laptop?
Thanks in advance.
The roaming behaviour is defined by the supplicant. The default Microsoft supplicant can roam between different wireless networks and automatically connect to hotspots.
I am knowing about the Odyssey Funk supplicant that it will only allow one connection profile.
The there is a Reliable Access Client that enables the definition of multiple profiles and will switch automatically between these networks.
But I did not yet hear about PWC. If it is an industrial designed supplicant, it may behave like the Odyssey Funk Supplicant and only connect to one defined network.
Normally the OEM will provide an option to switch from there supplied supplicant back to MS ZeroConfig. Did you try this?
If the supplicant only allows one profile it is hard programmming a tool that watches the networks and switches from one to another.

What blocks a .NET executable from creating a listening TCP port on localhost?

I have an application that creates a HTTP server on a random port (50000-59000) on "localhost". It tries to connect to this port afterwards to determine if everything was setup correctly and is ready to use.
This seems to work on most machines very well. Its written in C#.NET 4.0 for Windows XP and higher.
Now I have the problem that on one server at one customer the creation of the server seems to work but it can't connect to it. Sadly we didn't any information as the exception details were not outputted from this software as it has happened.
It works if the file is on local disk. If they start it from a specific Windows network share it stops working. I think that the have a special setting which causes this issue. But I don't know that could be reason.
My Question:
Do you know settings, an system administrator could make, that prevents a software, running as normal user, to connect to a listening port, that the program has opened just a moment ago? May be group policy settings in the active directory?
I've written a test program to try this again at our customer.

Sharing a folder fails due to WINS name resolution

I am trying to set up a shared folder with an old Win CE 5.0 device I am using to learn and improve my C# skills.
Possible options to do this can be done via console: net use sharedfolder \\mypc /user:foo /password:bar, to start an extra process from my C# application which then runs the console with the previous parameters or by using the function WNetAddConnection3.
However, I receive every time Error 53, ERROR_BAD_NETWORK_PATH.
I have checked the connection, as well as the path - always error 53.
A connection between another PC and \\mypc works fine without any problems. By comparison of my PC's network connection with the Win CE 5.0 device I have found out that there is only one difference: the Win CE 5.0 device has one WINS-server less. After setting the IP profile manually (IP Address, Subnet Mask, Default Gateway, DHCP, WINS), as well as adding the missing WINS-server, the problem disappears and the folder has been mounted successfully.
How can I fix this problem without changing the IP profile by hand?
In a normal network the WINS will be set by the DHCP server. The WINS entry of a network connection can also be set manually.
The problem with network sharing on Windows Mobile (WM) and Windows CE (WCE) is that it does not allow IP addresses, it only accepts windows network names. If you do not have WINS, a netbios network name can be resolved by the network card using a hosts entry, a broadcast or a WINS server.
As you do not have access to the DHCP settings of ActiveSync, you can either set WINS manually or by code or simply add a host entry for the connected PC. The activesync connected PC will can act as WINS server or , when you enter the netbios name for the netbios share server, the device can simply translate the netbios name to an IP. So either use the activesynced PC or the netbios server IP address as a WINS entry or add the name and IP of the sharing PC to the WCE/WM hosts table (registry: http://windowsmobilepro.blogspot.de/2006/04/etchosts-file-equivalent-in-windows.html).
[HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts\hello]
"ipaddr"=hex:a1,a3,a5,a9
"ExpireTime"=hex:99,99,99,99,99,99,99
I recommend to use the hosts entry solution and enter the name to use and the IP of the server you want to use.

How to show the value of a variable in android (read from a PC program periodically)

I am writing an invoice program that monitors the state of the invoice on an android tablet. For simplicity consider the invoice as an integer variable that dynamically is changed in the PC program. How can I show the last value of the variable in the tablet? In fact, the customers see the last state of their order in the tablet, while the main program is running in the PC. My first initial guess is to simulate a web server in my PC (for example using IIS or wamp) and periodically request the value from it and show the result in the tablet. But I think this is not optimal and depletes the tablet battery. Do you have any better Idea?
PC Platform: windows 7
PC programming Language: C#
PC DB: Access
Android version 2.3
This is my sample code written in C# in the PC. I want to see the value of ''i'' on Tablet.
class sample
{
// I want the variable to be visible from the tablet
public int i;
}
** EDIT: **
My program is a standalone desktop program written in C#. My database engine is MS ACCESS. The security is not important for my case (at least for now), TCP connection through wifi is preferred (between PC and tablet), but if bluetooth has any advantage, I can also use it.
If you're on a secure network and you're trying access a MS Access DB, then you probably need a 3rd party vendor driver like this:
http://www.easysoft.com/applications/microsoft-access/jdbc-odbc.html
since most JDBC drivers assume the DB is local, like this:
http://www.codeproject.com/Articles/35018/Access-MS-Access-Databases-from-Java
and then connect you Android app to it using TCP:
Android client and Java server TCP communication
Reading from a PC program (not a database) will require either reading flat files directly (where the data is stored or persisted) or writing your own data access driver (so that you make it accessible on a TCP port).

Categories