Building a Volume Shadow Service app for release - c++

How should an application that uses the Volume Shadow Copy service be built for release? I've been building and testing in Windows 7 and everything looks good so I built the app to test in Windows XP and I get an error on startup:
The procedure entry point VssFreeSnapshotPropertiesInternal could not be located in the dynamic link library VSSAPI.DLL
Now, I realise that a way round this is to use LoadLibrary and call the function if it exists but surely the function should exist in the first place to be able to use VSS?
I read somewhere that I would need to build a different version for XP, Server 2003, Windows 7 etc but I've not seen that in other applications that use VSS.
What is the correct way to build a VSS app?
Thanks,
J

Take a look at HoboCopy source code.
This should answer every question you could have.
It's free (for personal use) and C++ src code covers all Windows versions from XP to 2008.
Src has moved, anyway start from here.

Note: The Windows SDK can be used to develop VSS applications only for Windows Vista and later Windows operating system versions. It cannot be used to develop VSS requester's, providers, or writers for Windows Server 2003 R2, Windows Server 2003, or Windows XP.
link: VSS Application Compatibility (Windows)

Related

Prevent start of program on an old Windows system

We have a minimum System requirement of Server 2012 and Windows 8.1.
We have programs written on C++.
Some programs in our Setup still don't use newer DLLs and start on a Windows 7 or Windows 2008 R2. Some use newer DLLs and don't start with a message that such a DLL isn't found.
Is there a way to prevent the start of a program on an old Windows System with a manifest or something similar? I would prefer that the user don't see a "DLL not found message".
The best way: Windows Loader tells the user that the executable doesn't match this OS.
I know that this works for Windows executables of the OS. Copying a newer EXE from Windows 10 to an old Windows version, even if new specific DLLs are not used.

api-ms-win-core-winrt-string-l1-1-0.dll is missing from your computer

I'm writing a program that needs to run across Windows 7, 8.x and 10. The program has a one (relatively minor) feature that relies on Windows APIs that are only available on Windows 10. This feature will obviously not work on Win7, and before calling these APIs I make sure that the current OS is Windows 10.
In order to use these APIs I'm forced to configure my VS2015 project to "Consume Windows Runtime Extension" (/ZW) and to set "Target Platform Version" to 10.0.10586.0.
However, this causes a problem when I try to run the app on Windows 7. I get an error dialog saying "The program can't start because api-ms-win-core-winrt-string-l1-1-0.dll is missing from your computer". I tried to installed VS2015 redistributable package on the Win7 machine, but that did not solve the problem.
Any idea on how to get this to run on Win7? I really prefer not to change all my code to dynamically load all Windows 10 functions.
The program is written in C++, and the Windows API I use are from Windows.Devices.WifiDirect namespace.
I ended up solving this problem by moving all my Win10-only API calls into a proxy DLL, which is compiled with /ZW. I then removed the /ZW switch from the main program, which then allowed it to run under Windows 7. The proxy DLL is only loaded (using LoadLibrary() call) when my program is running on a Windows 10 machine.
This solved the problem. I did have to write a few proxy functions for the DLL, but it was far lass overhead than doing that for all the Win10-only API calls.
I would still like to hear better solutions, if there are any.
It is possible to access Windows 10 APIs without using /ZW switch by using the "ABI" API. More details here:
https://blogs.msdn.microsoft.com/oldnewthing/20160629-00/?p=93775
You'll have to use APIs like "RoGetActivationFactory" and "WindowsCreateString" through LoadLibrary/GetProcAddress, since you can't link to them as they're not available on Windows 7. Don't forget to define your WINVER and _WIN32_WINNT to Windows 7:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
That will allow you to not link to any APIs not available on Windows 7.

How to make Ws2_32.lib work with VS 2013 Project targeted at Windows 8.1

So I have a Visual Studio 2013 Update 4 solution with 2 projects inside, one target Windows 8.1, other Windows Phone 8.1 configured to build static lib.
Project is open sourced, so here is the solution for reference:
https://github.com/gideros/gideros/tree/master/winrt
What I need to do, is to make it use networking code, which uses winsockets. Since this is a library project, there was no Linker section in project properties, so I simply included
#include <WinSock2.h>
#pragma comment(lib, "Ws2_32.lib")
Both projects built without errors and when library included in Windows Phone app, it worked exactly as expected, but in Windows app networking part was not working, but also no errors or crashes.
I ran it through App Certification program and it said:
Error Found: The supported APIs test detected the following errors:
API WSACleanup in ws2_32.dll is not supported for this application type.
and lots of other references to ws2_32 library
I started searching on internet, and there were lots of posts stating that you can't use winsocket on Windows 8.1, you have to use Microsoft's winrt socket implementation etc.
But then I stumbled on this blog announcing that it is now (since VS 2013 Update 3) possible to use winsock on both Windows 8.1 and Windows Phone 8.1
http://blogs.windows.com/buildingapps/2014/10/13/winsock-and-more-open-source-for-your-windows-store-apps/
Quoting:
We’re happy to announce that starting with the release of Visual
Studio 2013 Update 3 (download) in August, the Windows App
Certification Kit (WACK) allows use of WinSock APIs in your Windows
Store apps. And since WinSock was already allowed to pass
certification on Windows Phone, this work completes the story. Now
WinSock is available universally across Windows 8.1, Windows Phone
8.1, and universal apps.
As I had VS 2013 Update 4, it should have already worked. So I checked App certification version (it was 3.3), and it stated it had update available, so I downloaded Windows SDK for Windows 8.1 from:
https://dev.windows.com/en-us/develop/app-certification-kit
And now I can't even build the project, because it says that all Ws2_32.lib parts are missing for Windows 8.1 target. (while Windows Phone 8.1 still builds and works as expected)
So is it even possible to use winsockets on Windows 8.1 apps?
And if yes, what am I missing?
Update 1:
It seems to be possible, but the problem is with my set up.
When I check the header files where my project points, then they are:
for Windows phone its
Program Files (x86)/Windows Phone Kits/8.1/Include/winsock2.h
for Windows it
Program Files (x86)/Windows Kits/8.1/Include/um/WinSock2.h
And when I check the file that is for Windows, then it has a preprocessor defined:
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
And it does not go into this if statement, thus for compiler this file is basically empty
I even tried to uninstall Windows 8.1 SDK, which did not change anything.
Then I manually removed files from Program Files folder and installed a new one from
https://dev.windows.com/en-us/develop/app-certification-kit
still I have the same header. So where do I get latest Windows 8.1 SDK with proper winsock2 header file?
Update 2:
So I removed everything and re-installed clean VS 2013 Express Update 4 and again same result, it all builds without errors, but networking does not work on Windows 8.1 app, while it perfectly works on Windows Phone 8.1.
It is like Windows 8.1 have only empty stubs, that do nothing.
I've been asking in Windows developer forum and one of the Microsoft representatives stated that, quoting:
If you have VS 2013 Update 4 properly installed, then you will have
gotten an updated Windows 8.1 SDK. In that version of winsock2.h, only
the ASCII versions of most of the WinSock APIs are excluded from
Windows Store. You have to use UNICODE exclusively for Windows 8 Store
apps.
Unfortunately I have no idea what that means and how should I proceed. If that means defining UNICODE macro then it is already defined.
Update 3:
I've managed to debug the winsocket code and everything is running as expected there, server is listening on the port. But nothing can connect to it. It's like it is running in sandboxed mode
Update 4:
Running netstat and wireshark all seems to work correctly and see server and I can even connect to it from other computer. But I can't connect from the same computer.
And it seems that MS forbids Windows apps to communicate with desktop apps on the same machine
I have no idea why, anyone can provide any insights?
How can a Metro app in Windows 8 communicate with a backend desktop app on the same machine?
The last question is
If VS 2013 Update 4 bundles winsock2 header that builds with WACK 3.3 that does not allow winsockets, while Windows 8.1 SDK update has WACK3.4 that allows socket API, but bundles older winsock2 header which does not build.
How to get WACK3.4 with correct winsock2 setup?
WinSock is supported on Windows and Windows Phone, and is allowed using WACK 3.4. It works for me using both #pragma comment(lib, "ws2_32.lib") and by adding ws2_32.lib directly to the project settings.
It looks like there is something wrong with the way you are building the project after the upgrade; can you post the errors you got after the upgrade?
So basically sockets do work, but there are couple of cases to be aware of.
There is a network isolation, which does not allow to connect to Windows Store apps from same machine (as I did in my tests and thought networking does not work).
But if you can connect from remote machine, everything works as expected.
More info on that:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd374089%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
But you still won't be able to pass WACK (which is not needed to submit to store, but still)
Problem is that VS 2013 Update 4 bundles winsock2 header that builds and works and it has WACK 3.3 software that does not allow winsockets.
While Windows 8.1 SDK update has WACK3.4 that allows socket API, but bundles older winsock2 header which does not build and work.
As you don't need to run WACK to submit app, mostly it won't be a problem, but as I needed to check if there are any other specific libraries I use, that can be prohibited, then I had to only install single (App certification) component from Windows 8.1 SDK from here:
https://dev.windows.com/en-us/develop/downloads
And I have WACK 3.4 and proper winsockets now
Still too bad about network isolation, that basically kills the purpose of what I was porting in the first place. Making all the work basically in vain.

Run software from USB device

I am developing a desktop based application using VC++.
I have stuck on one problem that the application should run through USB too.
I have searched for the answer I get to know that I can do it by changing installation path to USB device from this Link.
But my application needs some supporting platform like .Net Framework 4.0 Client Profile, and some redistributables for running application.
So, Can anyone tell me how can I make my application running through USB?
Thanks in advance.
regarding .Net Framework 4.0 Client Profile
As far as i know the .Net runtime can not be included in an Application.
The PC you want to execute your Application on needs to have the proper Runtime Version installed, it doesn't matter if its running from USB or not.
Here is a good article about the topic:
http://johnhaller.com/useful-stuff/dot-net-portable-apps
it basically concludes that you have to chose the .Net version depending on your target OS.
for Windows Vista and Windows 7 it would be .Net 2.0,
for Windows 8 it would be .Net 4.0
There might be a solution using Portable.Net or Mono but thats a bit above my developer skills :)
regarding redistributables
it really depends on what kind of redists you mean, if its the visual c++ redist you only need to include the right DLL, for other redists im not sure.
Btw Apps running from USB Sticks are usually called 'portable app', if you search for dotnet portable apps you can find quite some information.

Programming on an ARM tablet

Not sure whether to ask this here or on SuperUser... so please migrate it if required.
I was recently gifted an Asus Vivo WinRT tablet by my boss and I was looking forward to having a little portable testing environment.
Unfortunately, it contains an ARM processor and, as far as I can see, there are no development tools that will run on it. Everything is x86/x64.
Is there anything I can use to develop on the actual tablet itself? If not .NET, then perhaps a C and/or C++ compiler? SQL even? Anything? I'm having heaps of trouble finding anything myself.
No, there is not. You'll need to use visual studio 2012 and create a windows store application. From there you can build your app and side load it to the tablet. There is a component you can install on rt that will enable you to debug the app as it runs on the tablet however, this comes with vs.
Most apps for any tablet are developed this way, as tablets usually less than ideal development machines.
The only way at the moment is to use remote desktop. use the RDP client on the RT slate to connect to a PC with visual studio installed.