Salome HOME
Debug under Windows + some minor corrections.
authorrnv <rnv@opencascade.com>
Thu, 19 Aug 2021 12:24:41 +0000 (15:24 +0300)
committerrnv <rnv@opencascade.com>
Thu, 19 Aug 2021 12:24:41 +0000 (15:24 +0300)
src/SMESHUtils/SMESH_MGLicenseKeyGen.cxx

index e1d2db8d240afc2bca713568023696fce087c0eb..18289801d3624d3aa5a12b3e3b0608522406e313 100644 (file)
@@ -152,12 +152,16 @@ namespace
                                  0,
                                  NULL
                                  );
-    if ( msgLen > 0 )
-      error = (char*) cstr;
-
-    LocalFree(cstr);
+    if ( msgLen > 0 ) {
+#if defined( WIN32 ) && defined( UNICODE )
+      error = Kernel_Utils::encode((wchar_t*)cstr);
+#else
+      error = (char*)cstr;
+#endif
+      LocalFree(cstr);
+    }
 
-    return msgLen;
+    return (bool)msgLen;
 
 #endif
   }
@@ -244,11 +248,11 @@ namespace
 
 #ifdef WIN32
 
-    std::string outFile = tmpDir + "libMeshGemsKeyGenerator.dll";
+    std::string outFile = tmpDir + "MeshGemsKeyGenerator.dll";
 
     // use wget (== Invoke-WebRequest) PowerShell command available since Windows 7
     std::string psCmd = "wget -Uri " + url + " -OutFile " + outFile;
-    std::string   cmd = "start powershell.exe " + psCmd;
+    std::string   cmd = "powershell.exe " + psCmd;
 
 #else
 
@@ -273,8 +277,10 @@ namespace
     SMESH_File resultFile( outFile, /*open=*/false );
     bool ok = ( resultFile.exists() && resultFile.size() > 0 );
 
-    if ( ok )
+    if (ok)
       libraryFile._name = outFile;
+    else
+      error = "Can't download file " + url;
 
     return ok;
   }
@@ -357,6 +363,7 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
     if ( !loadLibrary( error, libraryFile ))
       return false;
 
+    bool ok = false;
     typedef bool (*SignFun)(void* );
     SignFun signFun = (SignFun) GetProc( theLibraryHandle, "SignCAD" ); 
     if ( !signFun )
@@ -364,20 +371,20 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
       if ( ! getLastError( error ))
         error = SMESH_Comment( "Can't find symbol 'SignCAD' in '") << getenv( theEnvVar ) << "'";
     }
+    else 
+    {
 
-    bool ok;
-
-    SMESH_TRY;
-
-    ok = signFun( meshgems_cad );
+      SMESH_TRY;
 
-    SMESH_CATCH( SMESH::returnError );
+      ok = signFun( meshgems_cad );
 
-    if ( !error.empty() )
-      ok = false;
-    else if ( !ok )
-      error = "SignCAD() failed (located in '" + libraryFile._name + "')";
+      SMESH_CATCH( SMESH::returnError );
 
+      if ( !error.empty() )
+        ok = false;
+      else if ( !ok )
+        error = "SignCAD() failed (located in '" + libraryFile._name + "')";
+    }
     return ok;
   }