In some cases on Windows, activation request XML file does not get written to user's desktop.Answered

Just curious if anybody has reported this error before?

My app is written in C++

Here is the code where we determine the path to the User's Desktop.  This work is 98% of all cases.

        TCHAR pathToHome[MAX_PATH];
        string desktopPath;
        wstring fullPath_w;
        if (SUCCEEDED(SHGetFolderPath(NULL,
                                      CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE,
                                      NULL,
                                      SHGFP_TYPE_CURRENT,
                                      pathToHome)))
        {
            wstring homeDirectory(&pathToHome[0]);
            string homeDir(homeDirectory.begin(), homeDirectory.end());
            desktopPath = homeDir;
        }

Here is the code that actually write the offline activation request XML file:

string reqFilePath = "\\Offline-Activation-Request.xml";
string fullPath = desktopPath + reqFilePath;
CA2W fullPath_ca2w(fullPath.c_str());
fullPath_w = fullPath_ca2w;
hr = TA_ActivationRequestToFile(taHandle, fullPath_w.c_str(), NULL);

Only in some cases does the file NOT get written.  Is there anything you see that is amiss from the code?

I do see the possible return codes which obviously include the error codes.  But, my question is what circumstances about the machine configuration would cause the file to not get written?  Would it be that there are NO network adapters so that TA-E-ENABLE-NETWORK-ADAPTERS is returned?  I mean, if a machine is offline maybe it doesn't have network adapters in the first place? What is the most common error code out of the following to be returned if the code works MOST of the time?

Possible return codes:
TA_OK, TA_FAIL, TA_E_PKEY, TA_E_INVALID_HANDLE, TA_E_COM,
 TA_E_EDATA_LONG, TA_E_INVALID_ARGS, TA_E_ANDROID_NOT_INIT, TA_E_ENABLE_NETWORK_ADAPTERS

 Any insight is appreciated.

Thanks!

Answer

Would it be that there are NO network adapters so that TA-E-ENABLE-NETWORK-ADAPTERS is returned?
 

Not likely these days. That error isn’t possible on modern Windows (8 and newer). Not unless something is severely broken.

Basically report all errors to the user. If you get TA_OK and the file isn’t there then something intercepted it. Likely an anti-virus.

Only use Windows built in AV. Everything else is garbage.