Home » Community » Coffee corner » Is it possible ? (Question about casting ptr to string then cast it back in another process)
Is it possible ? [message #51757] |
Thu, 16 May 2019 13:55  |
 |
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello Community !
Today I asked myself a question:
Here is part on code on my "OldVersion.exe"
const int VERSION = 1;
std::string s = std::to_string(VERSION);
bool needAnUpdate=false;
s << " " << &needAnUpdate;
char* cmd =(char*) s.c_str();
BOOL result = CreateProcess( "C:\\Upp\\upp\\out\\MyApps\\MINGW.Debug.Debug_Full.Noblitz\\newVersion.exe", //New Version const int is 2
cmd, NULL, NULL, // here we past version of current .exe
NULL, NULL, NULL, NULL,
&lpStartupInfo,
&lpProcessInfo
);
if (result)
{
if(needAnUpdate){
//Then my soft need to update itself.
}
}
As you can see, this old version have const int VERSION = 1.
here is NewVersion.exe :
const int VERSION =2;
if(argc > 1){
Upp::String arg(argv[1]); //transform args to string
Upp::String version = arg.Left(arg.Find(" ") -1); //here I get version
pp::String addrBool = arg.Right(arg.GetCount() - arg.Find(" ")); //Here I got adresse of my Boolean at string format
int versionToTest = std::stoi(version.ToStd());
if (VERSION > versionToTest){
// Here I cast my addrBool (string) to bool* (I dont know how to do it :/ )
}
//Here I end the programme
}
with this "methode" I should be able to know if oldVersion is outdated.
But it's possible ? It's a good idea to do those "stranges" things ? Maybe I should just use a textFile holding current version of newVersion.exe ?
Thanks for taking time to read and respond my Strange question.
Best Regard,
Xemuth
|
|
|
Goto Forum:
Current Time: Sat May 10 19:17:00 CEST 2025
Total time taken to generate the page: 0.02979 seconds
|