Is there a way to access the netsh API (e.g. WIN32 API, WDK)?
For example, I'm trying to get mobile broadband information via netsh with the following command:
netsh mbn show interfaces
So I guess the real question is: what's the actual programmatic representation of netsh mbn show interfaces using Windows SDK methods?
An example in pseudo code:
MBN_DEVICE mbn;
GetMbnDev(&mbn);
char* Name = mbn.Name;
char* IMEI = mbn.IMEI;
char* DeviceId = mbn.DevId;
float signal = mbn.Signal;
What APIs (Win32/.Net/.Core) would I have to call to get the same result in a data structure like with the command above?
Some of the Microsoft tools use internal/undocumented APIs to perform their work so cloning them often require a bit of investigation.
The first step is to download Dependency Walker and take a look at the functions netsh imports. In this case it does not look like it imports a lot of network related stuff (on my Windows 8 machine) but it does import CoCreateInstance and GetProcAddress so you can set a breakpoint on both in your debugger, this should allow you to determine the functions/interfaces it ultimately ends up calling.
Even before you get that far you can simply Google "Mobile Broadband API", it should lead you to this MSDN page. You should take a look at those interfaces and see if they provide the information you are after...
I found the answer right on this link: https://social.msdn.microsoft.com/Forums/vstudio/en-US/2d810752-f647-41f6-9299-27b6adddd536/how-to-get-the-signal-strength-from-a-mobile-broadband-network-adapter-in-windows-7-using-c?forum=csharpgeneral
Add a mbnapi_uuid.lib to your C++ project (Linker->Input->Additional
Dependencies).
Add a reference to COM Tab for C# project: 'Definition: UCM Extension
API for MBN Type Library'
Related
i work with c++ programming, I use an example for understanding main of my question.
Suppose, we want get current username in windows operation system, we can use follow code :
#include <windows.h>
#include <Lmcons.h>
char username[UNLEN+1];
DWORD username_len = UNLEN+1;
GetUserName(username, &username_len);
also, we can use wmi by follow the instruction explained on here and use Win32_ComputerSystem.UserName .
so, I hope you have fully understood, what's different between wmi and using api or any other way?
tank you for your response.
disadvantage :
Speed (mainly disadvantage)
if user turn off wmi service, wmi doesn't work.
advantage :
Wraps the native API
richer data, if you use wmi, you can get rich data
standardized, all the 'entities' are represented in a standardized way
These are the most important issues for using wmi.
Windows Management Instrumentation (WMI) is a set of specifications from Microsoft for consolidating the management of devices and applications in a network from Windows computing systems.
It is Microsoft implementation of Web-Based Enterprise Management.
WMI - Services are installed on Windows OS, but the service can be turned off. So if user disabled the service you wont get any information about the system. It is just for reporting purpose.
Whereas the APIs are ways thru which the Microsoft provides the access to the information to local Application and some how you can also manipulate the information provided.
WMI is query Based and its run very slow where as API are much faster to run .
Ex :- if you wanna check some System specification in your application before startup you should better use APIs . This will make you app Start faster.
WMI has advantage over api call WMI information is richer and easy to read where as to get that kind of same result we have to make several api calls .
The GetUserName API is merely a call to the function exported by the Advapi32.dll wich belongs to base kernel functions.
Using Win32_ComputerSystem class you are going to query Windows Management Instrumentation which is a complex and comprehensive infrastructure services which deals with most of the administrative tasks on Windows.
Posting a query to WMI involves much more resources and execution time so, if your goal is simply getting the user name, I suggest you to rely on the GetUserName API.
Given the ip address and an iSCSI Qualified Name (iqn) of an iSCSI target as an input I need to write C++ or C# code that uses VDS (documented at http://msdn.microsoft.com/en-us/library/windows/desktop/bb986750(v=vs.85).aspx) to log into this iSCSI target.
I think that I could use the function IVdsIscsiInitiatorAdapter::LoginToTarget documented at
http://msdn.microsoft.com/en-us/library/windows/desktop/aa381779(v=vs.85).aspx. How do I create the target object and the target portal object so that I can pass their ids to this method as arguments?
I believe that I must have a hardware provider installed to be able to connect to iSCSI target.
If you need a target API then you should look here:
http://msdn.microsoft.com/en-us/library/windows/desktop/hh830439(v=vs.85).aspx
Be prepared to deal with WMI and it's a pain... Few samples in PowerShell (it would be
easy to translate to C++ or C# as it's WMI basically in any case):
http://technet.microsoft.com/en-us/library/gg278022.aspx
For initiator side (client) you'd look here (continued with the next post)
(continued)
http://technet.microsoft.com/en-us/library/hh826099.aspx
http://blogs.msdn.com/b/san/archive/2012/07/31/managing-iscsi-initiator-connections-with-windows-powershell-on-windows-server-2012.aspx
And general one (continued with the next post)
(continued)
http://blogs.technet.com/b/filecab/archive/2012/06/08/iscsi-target-cmdlet-reference.aspx
Other Windows iSCSI targets have similar things. DataCore is scriptable with PowerShell and StarWind is coming with StarWindX OCX component you can call with PowerShell, C++, C# and VB.
I'm currently attempting to developing a small application / dll that will read a remote directshow filter graph and glean information from it for display in a "now playing" style plugin or script. After a few days of reading and subsequent testing, I realized that after getting the filter graph address from the ROT I was failing to convert it from the IUnknown interface pointer to IFilterGraph until I had registered "proppage.dll" which came with Windows SDK.
So what I am asking is, is there no other way to glean any information from a remote filter graph without having to register proppage.dll?
You can't call a COM interface from another address space unless you marshall the interface pointers and parameters/return values to and from the other process. For COM, you need to register a marshalling object for each interface that you want to be able to use cross-process. The standard implementation for that is in proppage.dll.
I don't think there is a simple way to access the interface without providing marshalling. If you don't want to use proppage.dll, you can build marshalling code from the IDL files supplied with the SDK and compile that into your own app.
G
does anyone have a clue how I can read values from the windows registry of a remote host (presuming I have sufficient rights). I mean by software/ my own written code. I need this for my tool e.g. to get a list of installed software on that machine.
Is this possible in C,C++, or even Qt?
Do I have to use some MSDN commands?
Please see new questions below; 32-bit <-> 64-bit problem.
Have a look at the RegConnectRegistry function in MSDN. This allows you to open a handle to a remote registry key and then use the standard registry APIs to interact with it.
I need to do a number of network-related things in C++ that I would normally do with ifconfig in Linux, but I'd like to do it without parsing the output of a group of system calls. Which C or C++ libraries can I use to tell if a network adapter is up or down, read or change an adapter's IP address and netmask, and change the default DNS gateway?
Basically you need to make a bunch of ioctl calls using a socket handle (SIOCGIFADDR, SIOCADDRT). You can find sample programs that use it in the Linux kernel source under Documentation/networking. Some other links that might be helpful:
Network Interface operations on AIX
XBMC's implementation (check out CNetworkInterfaceLinux)
EDIT: Let me also add that if your target is desktop linux, then you can consider using the DBUS API to query network parameters using the NetworkManager.
http://people.redhat.com/dcbw/NetworkManager/NetworkManager DBUS API.txt (sorry there's some issue inserting links in edits)
You can always look at ifconfig's source code to see how they did it in the first place: http://archive.ubuntu.com/ubuntu/pool/main/n/net-tools/net-tools_1.60.orig.tar.gz
The NetworkManager service exposes an API over dbus for querying/manipulating the networking on many distributions these days. This may be too high-level for your purposes (e.g. you require finer control of the network, or dbus/NetworkManager are not available on the system...), but it may provide you with what you need.
Check out the dbus C++ bindings and the NetworkManager API (sorry, I can't find a better formatted version right now, but the information is there).