|
includeh10 wrote: Do u know any idea to get Unique Windows ID to help me?
Have you considered Guidgen?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
includeh10 wrote: We find illegal copies of our software in several countries.
Welcome to the club!
What you can do, as others have done, is not use the Windows registration key, but use other things that are system specific. Here is a list of a few of them, in order of increasing fragility (i.e. likelihood of changing):
o CPUID value (Google for the CPUID instruction)
o Motherboard/BIOS ID
o Number of IDE/SATA controllers
o Geometries of physical drives (not partitions or drive letter, and be sure to allow for additional drives to be added)
o On-board devices (# of COM and Parallel ports)
o NIC address(s)
o Computer Name
Not all of the items are easy to get, mind you, and ones that are easy to get like drive letters, computer name, OS version/patch level, etc. are more likely to change, and remember that it is a serious PAIN IN THE ASS to have to contact a software vendor to get a new key each time you upgrade your memory or drives.
Be prepared for more users to contact you about system-level changes invalidating their system-locked installation.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Are there any functions to round the decimal value to its nearest decimal.
For eg:
1. float fVal = 5.26 The final result should be fVal = 5.30
2. float fVal = 5.23 The final result should be fVal = 5.20
using ceil it gives 6 and using floor it gives 5; but i m looking for nearest decimal.
Answers are appreciated.
|
|
|
|
|
Try adding 0.05 to the number.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If you need two decimal places, multiply with 100 and use ::ceil() or ::floor() , and then divide by 100.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
You can do...
float RoundedABit (float fVal)
{
fVal *= 10.0;
fVal = floor (fVal + 0.5);
fVal /= 10.0;
return fVal;
}
So, just shift it one decimal place, do your rounding, and shift it back.
You could probably also add 0.05, and use fmod .
Iain.
|
|
|
|
|
Thank You Iain good logic.
|
|
|
|
|
Iain had good answer for positive numbers.
RoundABit(-1.59999) would return -1.5, not -1.6 as it should.
Corrected to allow positive or negative, added Factor for variable decimal place position, and made it execute faster...
float RoundedABitToo (float fVal, float fFactor = 10.0)
{
return (floor((fVal * fFactor) + (fVal >= 0.0 ? 0.5 : -0.5)))/fFactor;
}
Gary
|
|
|
|
|
Thank You Gary for correction.
|
|
|
|
|
Silly question
<br />
main()<br />
{<br />
list[char*] pRecords = NULL; (*** proper list tag not used because HTML encoding ***)<br />
while(bRepeatForever)<br />
{<br />
pRecords = SomeFunc();<br />
ProcessRecords(pRecords);<br />
<br />
delete pRecords; <--- QUESTION: Do I need to delete individual list element?<br />
}<br />
<br />
...<br />
}
Then
list * SomeFunc()<br />
{<br />
char * pszData =NULL;<br />
...<br />
list<char*> pRecords = new list<char*>;
<br />
for(int i=0; i<1000; i++)<br />
{<br />
pszData = new char[10];<br />
pData=GetSomeData(i);<br />
strcpy(pszData, pData);<br />
pRecords->push_back(pszData);<br />
}<br />
...<br />
}<br />
Please note:
list[char*] pRecords = NULL; *** proper list tag not used because HTML encoding ***
|
|
|
|
|
If I understand your question and the related code :
yes.
|
|
|
|
|
You did not use the <pre>-tags for your code, so the < and > and anything in between are lost. So I can not see what type of list you created.
But in general, you need to delete every single object if you are having a list of pointers to objects you new ed. In that case, you could use smart-pointers (like boost::shared_ptr[^] [but not std::auto_ptr]) in your list.
Have you considered using a string class?
-- modified at 9:14 Thursday 23rd August, 2007
clickety
-- modified at 9:19 Thursday 23rd August, 2007
I did not read his code hard enough.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
jhwurmbach wrote: smart-pointers (like boost::shared_ptr[^] [but not std::auto_ptr])
why not standard ones ?
|
|
|
|
|
Reference counting vs. ownership differences may be significant depending on how the objects are used?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Because when you copy an auto_ptr , ownership of the object pointed to by the auto_ptr is transfered to the copying auto_ptr , and the copied auto_ptr is set to NULL.
So, simply copying an auto_ptr changes its value!
And internally, STL-container copy their content whenever needed. They require their content to be copy-constructible.
Also, the standard forbids containers of std::auto_ptr , but real-world STL-Implementation compile them nonetheless.
From "Scott Myers, Effective STL, Item 8"
For this reason, boost did invent smart pointers exhibiting a more intuitive behavior.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
|
Thanks, these are char*
They were gone because of HTML formatting!
Ang good beginner tutorial on Smart Pointer?
|
|
|
|
|
devvvy wrote: Ang good beginner tutorial on Smart Pointer?
Hmm - no, sorry. Google gives a lot of hints with tips, but no concise tutorial.
You construct them like this
boost::shared_ptr<Object> Obj( new Object);
and now use Obj like any pointer to an object: use as function parameters, return from function etc.
At the time when the last copy of the smart_ptr goes out of scope, the contained object is delete d.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
devvvy wrote: delete pRecords; <--- QUESTION: Do I need to delete individual list element?
Yes, since SomeFunc() allocated memory for it.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am trying to learn how to play with STL -- allocating/deallocating for list and individual list elements!
Note, all list contains char* list element:
list[char*] --- HTML formatting removed the proper tags...
<br />
#include [list]<br />
<br />
using namespace std;<br />
<br />
list<char*> * AllocateRecords() <br />
{<br />
list<char*> * pRecords = new list<char*>;<br />
char * pszData =NULL;<br />
<br />
for(int i=0; i<10000; i++)<br />
{<br />
pszData = new char[100];<br />
for(int j=0; j<100; j++)<br />
{<br />
pszData[j]='\0';
}<br />
sprintf(pszData, "Data#%d", i);<br />
pRecords->push_back(pszData);<br />
}<br />
<br />
return pRecords;<br />
}<br />
<br />
void ProcessRecords(list<char*> * pRecords)<br />
{<br />
<br />
return;<br />
}<br />
<br />
void DeallocateList(list<char*> * pList)<br />
{<br />
list<char*>::iterator oIter;<br />
char *pszData = NULL;<br />
<br />
if(pList==NULL)<br />
return;<br />
<br />
oIter = pList->end();<br />
oIter--;<br />
<br />
while(oIter != pList->begin())<br />
{ <br />
pszData = *oIter;
<br />
<br />
pList->pop_back(); <br />
<br />
<br />
pszData = NULL;<br />
<br />
<br />
<br />
oIter --;
}<br />
<br />
<br />
pList->clear();<br />
<br />
<br />
pList = NULL;<br />
<br />
return;<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
int nRepeat = 0;<br />
<br />
printf("begins!\n");<br />
<br />
list<char*> * pRecords = NULL; <br />
while(nRepeat<10000)<br />
{<br />
pRecords = AllocateRecords();<br />
ProcessRecords(pRecords);<br />
DeallocateList(pRecords); <br />
}<br />
<br />
return 0;<br />
}<br />
Many thanks!
-- modified at 23:03 Thursday 23rd August, 2007
|
|
|
|
|
devvvy wrote: Note, all list contains char* list element:
list[char*] --- HTML formatting removed the proper tags...
#include <list>
using namespace std;
typedef list<char*> charlist;
charlist *AllocateRecords()
{
charlist *pRecords = new charlist;
char *pszData = NULL;
for (int i = 0; i < 10000; i++)
{
pszData = new char[100];
for (int j = 0; j < 100; j++)
pszData[j] = '\0';
sprintf(pszData, "Data#%d", i);
pRecords->push_back(pszData);
}
return pRecords;
}
void ProcessRecords(charlist *pRecords)
{
charlist::iterator oIter;
for (oIter = pRecords->begin(); oIter != pRecords->end(); oIter++)
cout << *oIter << endl;
}
void DeallocateList(charlist *pList)
{
charlist::iterator oIter;
char *pszData = NULL;
if (NULL == pList)
return;
for (oIter = pList->begin(); oIter != pList->end(); oIter++)
{
pszData = *oIter;
delete [] pszData;
pszData = NULL;
}
pList->clear();
delete pList;
pList = NULL;
}
void main( void )
{
int nRepeat = 0;
charlist *pRecords = NULL;
cout << "begins!" << endl;
while (nRepeat < 10000)
{
pRecords = AllocateRecords();
ProcessRecords(pRecords);
DeallocateList(pRecords);
nRepeat++;
}
cout << "ends!" << endl;
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
I am developing XPCOM component for C++. I am following steps from following link
http://www.iosart.com/firefox/xpcom
Could you plz tell me that what is the difference between YOUR_INTERFACE_GUID and YOUR_COMPONENT_GUID? and from where can i generate those GUIDs..??
They say that use guidgen utility...but I am confused between above 2 ids..I don't know they are different or not..
Thanks a lot.
|
|
|
|
|
veer_in wrote: I don't know they are different or not..
Yes, they are different. One is for the interface, the other is for the component.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok. Thanks..
But could you please tell me how can i generate both? One from Visual studio \common\tools\bin.
And other from???
Plus which is what id? I am really not aware pf that..
Thanks.
|
|
|
|
|
veer_in wrote: But could you please tell me how can i generate both?
As suggested, use Guidgen.
If these concepts are foreign to you, perhaps a simpler project is in order.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|