I am going to put an network status icon in my GUI application. To get the network status notification, I am trying to use the Windows API. For this I am thinking to use NetworkAvailabilityChangedEventHandler in my application. I am very new to programming with the Windows API and framework. Can anybody help me in the following things:
Can the API NetworkAvailabilityChangedEventHandle only be used in C#?
Can I use it in C++ (Qt)?
Which header file must I include? (I checked in MSDN for this. but they are using namespace for this. All the examples are in C#. I am not able to understand how to implement it in my C++ code.)
I will be grateful if somebody can give me a detailed code snippet for using this windows event handler, including the .h file or namespace to be included.
Where did you get the idea to use the NetworkAvailabilityChangedEventHandler delegate?
That is explicitly not part of the Windows API, but rather a delegate function used by the .NET Framework in conjunction with the NetworkChange.NetworkAvailabilityChanged event. That explains why all the examples on MSDN are in C#—because this is only intended to be used in applications targeting the .NET Framework. If you're writing unmanaged C++ using Qt, then you're not using the .NET Framework, and you can't take advantage of its functionality.
The Windows API equivalent is the InternetGetConnectedState function, which returns a value indicating whether or not the system is currently connected to the Internet. You'll find that its MSDN documentation is substantially friendlier towards unmanaged C++ developers, because that's the
primary intended audience. The information that you're seeking is given at the bottom:
Header Wininet.h
Library Wininet.lib
DLL
Wininet.dll
You can find a list of all the WinINet functions here.
Related
Is it possible to use a Go API in a Qt C++ project?
I would like to use the following Google API written in Go: https://cloud.google.com/speech-to-text/docs/reference/libraries#client-libraries-install-go
Is it possible to use a Go API in a Qt C++ project?
It could be possible, but it might not be easy and would be very brittle to run Go and Qt code in the same process, since Go and Qt have very different thread (goroutine) and memory models.
However, Go has (in its standard library) many powerful packages to ease the development of server programs, in particular of HTTP or JSONRPC servers.
Perhaps you might consider running two different processes using inter-process communication facilities. Details are operating system specific. I assume you run Linux. Your Qt application could then start the Go program using QProcess and later communicate with it (behaving as a client to your Go specialized "server"-like program).
Then you could use HTTP or JSONRPC to remotely call your Go functions from your Qt application. You need some HTTP client library in Qt (it is there already under Qt Network, and you might also use libcurl) or some JSONRPC client library. Your Go program would be some specialized HTTP or JSONRPC server (and some Google Speech to Text client) and your Qt program would be its only client (and would start it). So your Go program would be some specialized proxy. You could even use pipe(7)-s, unix(7) sockets, or fifo(7)-s to increase the "privacy" of the communication channel.
If the Google Speech to Text API is huge (but it probably is not) you might use Go reflective or introspective abilities to generate some C++ glue code for Qt: go/ast, go/build, go/parser, go/importer, etc
BTW, it seems that Google Speech to Text protocol is using JSON with HTTP (it seems to be some Web API) and has a documented REST API, so you might directly code in C++ the relevant code doing that (of course you need to understand all the details of the protocol: relevant HTTP requests and JSON formats), without any Go code (or process). If you go that route, I recommend making your Qt (or C++) code for Google Speech to Text some separate free software library (to be able to get feedback and help from outside).
I wanted to extend an existing C++ application to use Evernote. I have downloaded the C++ SDK for Evernote and the Windows SDK for Evernote. The C++ SDK does not have any documentation. It just consists of a series of C++ files dating back to 2013. The Windows SDK documentation relates to C#. A great language, but not what my existing code is written in.
I have built the Thrift Library and linked it with my test application. I can get it to make an HTTP connection, but checkVersion gives me an EOF exception from THttpTransport::refill.
boost::shared_ptr User_Store_Http_Client = boost::shared_ptr(new THttpClient("sandbox.evernote.com", 443, "/edam/user"));
boost::shared_ptr User_Store_Protocol = boost::shared_ptr(new TBinaryProtocol(User_Store_Http_Client));
UserStoreClient* User_Store = new UserStoreClient(User_Store_Protocol, User_Store_Protocol);
User_Store_Http_Client->open();
User_Store->checkVersion("MyApp", evernote::edam::g_UserStore_constants.EDAM_VERSION_MAJOR, evernote::edam::g_UserStore_constants.EDAM_VERSION_MINOR);
The Windows SDK talks about EnSession objects, which don't appear in the C++ SDK? I am assuming that the C++ SDK is a raw EDAM implementation and that the C# API has a higher level to it.
Does anyone have a working example of C++ code that would help me get started? Where should I go for help on using Evernote from C++? Am I flogging a dead horse with this?
I am struggling to understand how I should use the Evernote C++ API and would appreciate some help.
I found this SDK
https://github.com/d1vanov/QEverCloud
Looks promising so far.
The problem
I would like to use c++ to create an application that uses the new macbook pro touch bar. However I am not able to find any really good resources. And apple does not have any docs on using c++ to program the touch bar.
What I have done
I found this article on c++ and the touch bar, However I cannot find either of the header files for the script GLFW/glfw3.h and GLFW/glfw3native.h. These both seem critical to the script working.
More on the issue
Even if the above article's script works, there are no official docs for programing the touch bar with c++ (That I know of). I think that this is an important thing to have given the fact that many, if not most applications are written in c/c++.
Thank you in advance for the help!
So the article that you link to basically does not need the GLFW/glfw3.h and GLFW/glfw3native.h files if you are not using GLFW.
What UI framework are you using for your C++ app?
Unless it is still using Carbon, at the lowest level, the framework will be creating NSWindows to actually have windows in the UI. You need to get access to the NSWindow that your framework is using to host it the UI. If it is still using Carbon, I think you are probably not going to be able to accomplish this.
If the framework provides some mechanism to get the native platform window (which will be an NSWindow), you would replace the author's call to glfwGetCocoaWindow(window); with the correct call from your framework.
If the framework does not provide access to the NSWindow, then you will need to use the code that is commented out at the bottom of the article to attach your touchbar to the windows in your app.
Please note that all that code is Obj-C code; you'll need to have at least one .m or .mm file in your project to provide that Obj-C glue code to get access to the touchbar. Basically that code is a C-calleable wrapper around the Cocoa API.
Also note that you'll need to expand the list of buttons and actions for all the different things you want to put in the touchbar. You could add your own wrapping API so that the construction of the toolbar is done from C++ and registers actions that call-back into your C++ app to handle the events.
Fundamentally though, the touchbar is not available on any other platform, so there is no great benefit to trying to avoid writing Obj-C to implement your touchbar as that code will only run on macOS anyway. If you use .mm files to implement Obj-C++ for this code, you can still call into your C++ objects from your touchbar code.
guys! I'm currently working on new cross-platform application (iOS, Android, UWP). I have graphical library for UI written in c++, using freeglut for opengGL.
The problem is, I don't know how to use this library in my UWP application. I have read a lot of information about all the wrappers for OpenGL, but they all for WPF or written in C++. I also know about Microsoft ANGLE Project, but it is written in the c++ too, but I need to write the application in C# language.
So, how can I modify my own library using excluding freeglut and import it into my C# application?
By the way, sorry for mistakes in my English.
So you want to consume your legacy C++ assembly in your UWP application?
You can create a Windows Runtime Component(Universal Windows) project, in which you need to include the assembly, and declare as many APIs as you want to expose, all marked with DllImport attribute.
Eventually, this WinRT component will do the Platform Invoke, and works as a "wrapper" layer between your legacy code and UWP application.
It's up to your preference which language you use for the WinRT component, C++ or C#, either way, you need to worry about struct/type mashalling and unmashalling.
After you're done with above, you'll be able to reference the WinRT component in your UWP application, and call the APIs you declared in that assembly.
The same way works for Microsoft Angle project as well.
You might find this post useful.
One last word, you might want to avoid using forbidden APIs, otherwise your UWP app won't pass the Windows Store Certification.
According to https://msdn.microsoft.com/library/windows/desktop/jj714080.aspx there is an option to use DirectX and some native API functions including LoadLibrary and GetProcAddress functions https://msdn.microsoft.com/library/windows/desktop/jj714080.aspx
This should give you ability to use any native dll.
You can try to make RuntimeComponent project and put it there. Also you can try clr oldsyntax option to use native code as it is.
I am using persevere for an application I am writing that controls remote hardwere.
Persevere is written in Java and doesn't supply an alternative API.
I am using a web-based GUI as the control panel. So far, so good.
I can get and set data using REST channels like dojo does but the problem is that I don't really know how to use REST channels. Which library should I use to do so?
If you use gcc as your toolchain you can embed a JVM with GCJ to run persevere inside your application. GCJ makes it easy to call C++ from Java with it's CNI interface (much easier than JNI). I used that method to use Java scripting inside our C++ application. You can even compile the persevere jar into a native library and link it to your app with GCJ.
The best reference is the GCJ Documentation.
There is also a Linux Journal contains the article Embedded Java with GCJ that you can read.
You can also study applications that use gcj.