//========================================================================== // // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright (c) Microsoft Corporation. All rights reserved. // //-------------------------------------------------------------------------- #include "SendToFaxRecipient.h" //+--------------------------------------------------------------------------- // // function: GiveUsage // // Synopsis: prints the usage of the application // // Arguments: [AppName] - Name of the application whose usage has to be printed // // Returns: void // //---------------------------------------------------------------------------- void GiveUsage(LPTSTR AppName) { _tprintf( TEXT("Usage : %s \n \ /o or \n \ /d Document that is to be sent as Fax \n"),AppName); _tprintf( TEXT("Usage : %s /? -- help message\n"),AppName); } //+--------------------------------------------------------------------------- // // function: IsOSVersionCompatible // // Synopsis: finds whether the target OS supports this functionality. // // Arguments: [dwVersion] - Minimum Version of the OS required for the Sample to run. // // Returns: bool - true if the Sample can run on this OS // //---------------------------------------------------------------------------- bool IsOSVersionCompatible(DWORD dwVersion) { OSVERSIONINFOEX osvi; BOOL bOsVersionInfoEx; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi); if( !bOsVersionInfoEx ) { osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) return false; } bOsVersionInfoEx = (osvi.dwMajorVersion >= dwVersion ); return (bOsVersionInfoEx == TRUE); } //+--------------------------------------------------------------------------- // // function: CorrectString // // Synopsis: Replaces the semicolon separated string with space separated string // // Arguments: [inputDocListString] - The list of documents in string format separated by semicolon // // Returns: bool: true if passed successfully // //---------------------------------------------------------------------------- bool CorrectString(LPTSTR inputDocListString) { bool bRetVal = false; if(NULL == inputDocListString) { return false; } HRESULT hr = S_OK; size_t iStrLen = 0; hr = StringCchLength( inputDocListString, 2056 , &iStrLen); if(FAILED(hr)) { _tprintf(_T("StringCchLength of inputDocListString failed. Error 0x%x"), hr); bRetVal = false; goto Exit; } //Replace ; with space size_t i = 0; while(i < iStrLen) { if(inputDocListString[i] == ';') { (inputDocListString)[i] = ' '; } i++; } bRetVal = true; Exit: return bRetVal; } int __cdecl _tmain(int argc, _TCHAR* argv[]) { HRESULT hr = S_OK; bool bRetVal = true; LPTSTR lptstrOption = NULL; LPTSTR lptstrDoc = NULL; bool bConnected = false; bool bResult = false; int argcount = 0; size_t argSize = 0; DWORD dwRet = 0; bool bFlag = false; bool bVersion = IsOSVersionCompatible(VISTA); //Check is OS is Vista if(bVersion == false) { _tprintf(_T("This sample is compatible with Windows Vista")); bRetVal = false; goto Exit; } #ifdef UNICODE argv = CommandLineToArgvW( GetCommandLine(), &argc ); #else argv = argvA; #endif if (argc == 1) { _tprintf( TEXT("Missing args.\n") ); GiveUsage(argv[0]); bRetVal = false; goto Exit; } // check for commandline switches for (argcount=1; argcount