|
|
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Changes in SysInfo Bazaar package (svn 6019)
Changes in SysInfo Bazaar package (svn 6019) [message #39812] |
Thu, 02 May 2013 20:48 |
|
BioBytes
Messages: 307 Registered: October 2008 Location: France
|
Senior Member |
|
|
Hi all,
I have noticed that the following code lines have been modified in SysInfo (Bazaar package) in svn 6019 when compared with svn 6009.
Upp svn 6009
long GetWindowIdFromCaption(String windowCaption, bool exactMatch)
{
Array<long> wid, pid;
Array<String> name, fileName, caption;
GetWindowsList(wid, pid, name, fileName, caption);
for (int i = 0; i < wid.GetCount(); ++i) {
if (exactMatch) {
if (caption[i] == windowCaption)
return wid[i];
} else {
if (caption[i].Find(windowCaption) >= 0)
return wid[i];
}
}
return -1;
}
Upp svn 6019
uint64 GetWindowIdFromCaption(String windowCaption, bool exactMatch)
{
Array<uint64> wid, pid;
Array<String> name, fileName, caption;
GetWindowsList(wid, pid, name, fileName, caption);
for (int i = 0; i < wid.GetCount(); ++i) {
if (exactMatch) {
if (caption[i] == windowCaption)
return wid[i];
} else {
if (caption[i].Find(windowCaption) >= 0)
return wid[i];
}
}
return INT64_MAX;
}
I understand that GetwindowIdFromCaption function should now return a 64 bits integer to consider 64bits platform but I am surprised that the negative result when a single instance is running has been replaced with the INT64_MAX value.
Is there a specific reason for that change?
This is not a real problem but it requires that part of code has to be written in some applications.
Have a happy coding
Regards
Biobytes
|
|
|
|
Re: Changes in SysInfo Bazaar package (svn 6019) [message #39818 is a reply to message #39815] |
Fri, 03 May 2013 19:40 |
|
BioBytes
Messages: 307 Registered: October 2008 Location: France
|
Senior Member |
|
|
Hello Koldo,
Thank you very much for explanation. I see now why the source code has been modified.
The "problem" I faced is that the new function GetWindowIdFromCaption has not the same behaviour under Win XP and Win 7. For some reason, my application checks if an instance is already running and therefore inform the user that only one instance can be opened on his/her computer.
Under Upp svn 6009, the code (working under Win XP or Win 7) was:
bool QSkillsWin::IsSingleInstance()
{
if(GetWindowIdFromCaption(GetTitle().ToString())>0)return true;
else return false;
}
Under Upp svn 6019, the new code is:
bool RegManager::IsSingleInstance()
{
if(IsWin7())
{
if(GetWindowIdFromCaption(GetTitle().ToString(),true)==INT64_MAX)return true;
else return false;
}
else
{
if(GetWindowIdFromCaption(GetTitle().ToString(),true)<INT64_MAX)return true;
else return false;
}
}
Without the above modification, the function is working well under Win 7 but return opposite value under Win XP showing a dialogue window informing the user that the application is already running in memory (?!).
My U++ project is compiled using MSC 9 on the two computers (one is running under XP, the other under Win 7).
If I would like to move my application under Linux, should I integrate a test to check that Linux or Posix is running ?
Thank you in advance for your comments
Regards
Biobytes
|
|
|
|
|
|
|
Re: Changes in SysInfo Bazaar package (svn 6019) [message #40006 is a reply to message #39820] |
Sat, 25 May 2013 15:45 |
o_wild
Messages: 28 Registered: December 2008 Location: Urmqi
|
Promising Member |
|
|
koldo wrote on Sat, 04 May 2013 02:00 | Hello BioBytes
Now all handles are int64 so all your code should work. The doc is updated.
Thank you for your patience
|
Line 219 of SysInfo_demo_console/main.cpp does not conform to the declaration of GetWindowsList in SysInfo/SysInfo.h, please check.
I changed "uint64" to "int64" and everything is ok.
alternatively,change the declaration to 'void GetWindowsList(Upp::Array<uint64> &wid, Upp::Array<uint64> &pid, Upp::Array<String> &name,Upp::Array<String> &fileName, Upp::Array<String> &title);'
Which is better?
Regards,
Wild
[Updated on: Sat, 25 May 2013 15:46] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Apr 26 10:44:49 CEST 2024
Total time taken to generate the page: 0.90888 seconds
|
|
|