Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced 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. Confused

Have a happy coding Very Happy

Regards

Biobytes
Re: Changes in SysInfo Bazaar package (svn 6019) [message #39815 is a reply to message #39812] Fri, 03 May 2013 09:30 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Hello BioBytes

First of all sorry for not explaining this change before.

The problem came from the Linux 64 bit version that complained about using long and int64 for this handlers so I changed them to uint64. This affects to process and windows handlers.

The problem is that there is not a Null for uint64 (and in general for unsigned types) so I simply took the INT64_MAX as a kind of Null considering this amount was enough high.

If you have a less ugly idea I will include it.


Best regards
Iñaki
Re: Changes in SysInfo Bazaar package (svn 6019) [message #39818 is a reply to message #39815] Fri, 03 May 2013 19:40 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced 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 #39820 is a reply to message #39818] Sat, 04 May 2013 02:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Hello BioBytes

Now all handles are int64 so all your code should work. The doc is updated.

Thank you for your patience Rolling Eyes


Best regards
Iñaki
Re: Changes in SysInfo Bazaar package (svn 6019) [message #39825 is a reply to message #39820] Sat, 04 May 2013 15:16 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced Member
Hi Koldo,

Thank you very much for your effort and information.

I update my doc immediately

Best regards

Biobytes
Re: Changes in SysInfo Bazaar package (svn 6019) [message #39834 is a reply to message #39825] Sun, 05 May 2013 14:31 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced Member
Hzllo Koldo,

I just updated my Upp system with svn 6031 and all is working perfectly with SysInfo and GetWindowIdFromCaption function and no need to modify my application sources. Very Happy

Thank you again

Regards
Biobytes
Re: Changes in SysInfo Bazaar package (svn 6019) [message #39836 is a reply to message #39834] Sun, 05 May 2013 15:59 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Smile

Best regards
Iñaki
Re: Changes in SysInfo Bazaar package (svn 6019) [message #40006 is a reply to message #39820] Sat, 25 May 2013 15:45 Go to previous messageGo to next message
o_wild is currently offline  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 Rolling Eyes


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

Re: Changes in SysInfo Bazaar package (svn 6019) [message #40013 is a reply to message #40006] Sun, 26 May 2013 15:25 Go to previous message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Thank you Wild

Fixed SysInfo_demo_console/main.cpp to int64 as all handles are int64 because sometimes it is used the Null value and uint64 does not have Null.


Best regards
Iñaki
Previous Topic: linker problem
Next Topic: [BUG] MscBuilder crashes the IDE when building all shared.
Goto Forum:
  


Current Time: Mon Nov 18 07:11:49 CET 2019

Total time taken to generate the page: 0.02000 seconds