Is there a way to register for WLan notifications using C++/WinRT? - c++-winrt

I am porting a Win32 application into WinRT using C++/WinRT.
Currently my Win32 application uses APIs WlanRegisterNotification and WlanNotificationCallback to get notified when a user connects to a WiFi router.
How can I achieve the same functionality using C++/WinRT ?

Not my area of expertise, but I believe the NetworkInformation::NetworkStatusChanged event should suit your needs:
https://learn.microsoft.com/en-us/previous-versions/windows/apps/hh700376%28v%3dwin.10%29
For most usage, it should give you similar information. The examples are in javascript, but should translate 1:1 to C++ WinRT in terms of types & namespaces. See also here:
https://learn.microsoft.com/en-us/uwp/api/windows.networking.connectivity.networkinformation
Thanks,
Ben (MSFT)

Related

Some questions about Windows' DLLs?

I wrote an application in a JS-based framework called Titanium. This framework doesn't have some functions, so I'm bundling autohotkeys, and using STDIN/STDOUT to connect the two. Autohotkeys has a cool function DllCall which allows to interconect with the operating system and should help me close the gap between the JS-based framework and the missing functionality.
To give you an example, Titanium allows me to bind to a specific port. But if I bind to 0 and let the OS pick a free port (as it should), it will work, but there's no way to tell which port it actually bound to.
Now since I come from web applications, DLLs are new to me; so I have a few questions:
Is there like a big doc with all the DLLs and all their methods?
How do I know if some methods are dependent on some services? I mean I've heard some rely on RPCs, COM, COM+, WMIs, etc. which a user can turn off and if it does, these methods won't work. Is there also a place where I can get more info on this?
Are there any off-the-shelf DLLs, with their methods, which I can trust that they will work 100% from XP up to 7?
Are there any access permissions I should know about? Are they documented.
If you also come from web programming, is there anything else I should be aware about?
Thank you very much.
You can find a (mostly) complete documentation of all Windows API functions (which reside in DLLs) either online on MSDN or offline using the documentation from the Windows SDK.
For example look at the documentation for SHGetSpecialFolderPath. There you can find various information, like the DLL (shell32.dll), any prerequisites (min. IE 4) and the platform availablity. (min. Windows 2000) Also security considerations are documented.
All API functions are documented more or less in this manner. A good starting point is the Windows Developer Reference. From there you can browse through the many API functions.
Basically the answer to every question is that you should search MSDN for the functions or APIs you are interested in and read the documentation there:
http://msdn.microsoft.com/en-us/library/ms123401.aspx
They document which operating systems the functions are available in so it should be easy to write something that works in Windows XP and up.

Microsoft COM specification replacement?

I understand that COM is really a way to program (i.e. like structured programming, or OO programming). However it is a little old. So I was just wondering what has really replaced this set of specifications? Will I find this in .NET documentation?
COM has not been replaced. The Component Object Model is a core part of Windows and will remain so for the foreseeable future.
COM provides you with one mechanism of inter process communication (communicating between applications on a machine), it is also used as a much simpler (for the consumer) system of sharing dlls. Its COM (or ActiveX, or OLE - all the same) that enables VBA to work so well in MS Office, it is the foundation of ActiveX controls.
COM is not a way to program (unlike OOP etc) it is a technology that works on windows to make access to other applications during runtime easier.
.NET can use COM object with wrappers, and if you want to allow any app to access your functionality, its still best to provide a COM wrapper.
Other methods of inter app coms now exist such as ZeroMQ.
The original specification for COM is old in age, but the specification as well as the concepts are still in use, and you can still create and consume COM objects.
For .NET, you can start by looking at the following links:
Com Interop Part 1: C# Client Tutorial (C#) # MSDN
Interoperating with unmanaged code # MSDN
In addition, there are other specs that are very similar to COM or have semantics that are the same. Most notably, XPCOM is in use in FireFox for their plugin spec and also used internally to FireFox to connectable objects.
XPCOM # MDN (Mozilla)
WinRT is an upcoming platform update for windows that is also heavy in COM concepts.
There are some useful here: Why is WinRT unmanaged # StackOverflow
For .NET developers, a lot of the declarative overhead is hidden as mentioned here: WinRT demystified - Miguel de Icaza
The head of the spec is here: The Windows Runtime # MSDN
And in the context of COM, developing WinRT components with C++ has similarities, although some syntax is borrowed from managed C++: Creating Windows Runtime Components in C++ # MSDN

API vs Toolkit vs Framework vs Library

My question is very simple, and I want a clear answer with a simple example.
What's the main difference between API, Toolkit, Framework, and Library?
I prefer following:
An API is an abstract description of how to use an application. For example, an API may describe the function syntax (declaration) of a chat server. i.e. login, publish_message, subscribe_messages. And, it describes any protocols to use the application. i.e. must login before sending or recieving messages, or clients are dropped after 2 minutes if not sending or receiving messages.
A library is an implementation of an API, it containes the compiled code that implements the functions and protocols (maintains usage state).
A toolkit is a set of libraries (API) and services grouped together to provide the developer with a wider range of possible solutions. For example, the Globus Toolkit provides services (such as File transfering, Job Subission and Scheduling) that a devleoper can install and start on their servers. They also provide API's to build applications that may use the services deployed in an integrated fashion. For example, the developer may build a program that uses the Job Submission API to communicate with the Job Submission Service.
A Framework is a set of guidelines that prevents inappropriate use or developement. The developer must contruct their applications within the rules and boundaries of the framework. This is done by forcing the developer to extend the current framework to develope new software. by extending the framework, you force adhearence to the framework.
I'm not saying these are completely correct, but its worked ok for me so far!
This has always been my understanding, you will no doubt see differing opinions on the subject:
API (Application Programming Interface) - Allows you to use code in an already functional application in a stand-alone fasion.
Framework - Code that gives you base classes and interfaces for a certain task/application type, usually in the form of a design pattern. (Though not always)
Library - Related code that can be swapped in and out at will to accomplish tasks at a class level
Toolkit - Related code that can be used to accomplish tasks at a component level.
Those terms sometimes are misinterchanged.
Similar posts, read:
What is the major difference between a framework and a toolkit?
Framework vs. Toolkit vs. Library
I prefer to call a library as an alias of module or namespace. Toolkit and A.P.I. is usually a set of libraries for a common task. Altought, A.P.I. is more used for Procedural Programming than Object Oriented Programming.

Free Modem Dialer

Is there a telephone application for modems that can receive a phone number as a parameter and manage the call for themselves? I ask because in my application I must implement a click2call functionality and may be is a free software out there that I can use and I do not have to fight with TAPI. Thanks!
Here are a few wrappers available to abstract away the complicated parts of using TAPI.
TAPI Wrapper
http://www.vbrad.com/article.aspx?id=61
Normally, the domain of C/C++ programmers, this wrapper code will allow you to skip all the complexity and get to work straight away.
ATAPI - Managed TAPI wrapper for TAPI 2.0
http://atapi.codeplex.com/
Managed .NET library for interacting with the Microsoft Telephony API (TAPI) 2.x. This library is for creating clients that consume telephony services on Windows XP or better.
WombatDialer does something like that for the Asterisk platform and has powerful APIs - see http://www.wombatdialer.com/manuals/WD_UserManual-chunked/ar01s08.html
It manages the call flow internally (scheduling, error conditions) and sends HTTP notifications of events.

Haptic feedback in Compact Framework 2 running on Windows Mobile 6.5

I'm writing a Compact Framework 2.0 application on Windows Mobile 6.5
Several of the built-in controls (e.g. button) produce haptic feedback - small vibrations - when clicked.
Is there any way the same thing can be achieved in custom controls?
I'm aware of some platform specific APIs for this - but I'm looking for a generic WM6.5 API to call if there is one.
There is no "generic" managed Windows Mobile mechanism for this. Your best bet is to abstract the implementation into an interface, then have it determine at run time what you're running on and instantiate the implementation based on that.
The LED notification API is probably the most common implementation by OEMs and I think would cover the majority.