From: jc on 30 Apr 2010 00:55 Hello, I found MS's example on "How to Validate a Serial Number". However, the process seemed long and confusing. Does anybody know of a tool, that automates the process, of validating a programmer-defined serial number ? TIA, -jc
From: Joseph M. Newcomer on 30 Apr 2010 02:28 Buy a third-party tool, or use one of the open source or free downloads. Nearly everyone who attempts this gets it wrong. joe On Thu, 29 Apr 2010 21:55:01 -0700, jc <jc(a)discussions.microsoft.com> wrote: >Hello, > >I found MS's example on "How to Validate a Serial Number". >However, the process seemed long and confusing. > >Does anybody know of a tool, that automates the process, >of validating a programmer-defined serial number ? > >TIA, >-jc Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Tom Serface on 30 Apr 2010 08:50 Something like this software package may work for you: http://www.indigorose.com/webhelp/sufwi/HowTo/Add_a_Serial_Number_Validation_Screen_to_Your_Project.htm Tom "jc" <jc(a)discussions.microsoft.com> wrote in message news:97197843-154C-49A8-8298-C1BB2C560BD9(a)microsoft.com... > Hello, > > I found MS's example on "How to Validate a Serial Number". > However, the process seemed long and confusing. > > Does anybody know of a tool, that automates the process, > of validating a programmer-defined serial number ? > > TIA, > -jc
From: Joseph M. Newcomer on 30 Apr 2010 10:50 See below... On Fri, 30 Apr 2010 07:50:08 -0500, "Tom Serface" <tom(a)camaswood.com> wrote: >Something like this software package may work for you: > >http://www.indigorose.com/webhelp/sufwi/HowTo/Add_a_Serial_Number_Validation_Screen_to_Your_Project.htm **** I have trouble believing this code was ever tested. For example: it does a memset of 0 to a 5-character buffer, which makes no sense, because the next line does an lstrcpyn of FIVE characters to the 5-character buffer, copying 5 characters, and (because of the definition of lstrcpyn) putting a NUL character in the space beyond the buffer! The memset was redundant, and the lstrcpyn is wrong; the length parameter is NOT the size of the buffer, but the number of characters to copy! So if you have an szPIDKEY of length > 5 (it should say > 4, or the buffer size should be 6) then it merely copies the first 5 characters into the buffer, follows them with a NUL, which clobbers some random piece of stack, and then compares it to a 4-character literal! If the ID was "12345" the code would never be executed, even though the serial number does have the first 4 characters be "1234". Sadly, this meets the defined criterion for correctness, but if you study the code, this particular ID would have been rejected. If the ID was "123456", the code copies "12345" and then compares it to "1234". So although it meets the criterion, the code will claim it does not. The first parameter to MessageBox is 0, which is sloppy programming, because what was intended was to write NULL; but even if corrected to represent good practice, the code is incorrect. Making the desktop the parent means the MessageBox MIGHT appear UNDERNEATH the app, or even some other random app (yes, this is what can happen, and I've seen it happen!), so it is an exceptionally poor example of how to do GUI programming. The need to introduce a new variable, szPropertyValue, to hold the strings "TRUE" or "FALSE" seems silly, but a beginner mistake; someone read the parameter to MsiSetProperty, saw that the parameter needed to be an LPCTSTR, and decided this meant that a variable of that type was required. Instead, it could have easily been written as MsiSetPropertyValue(hInstall, _T("VALID_SERIAL"), (bSerialIsValid ? _T("TRUE") : _T("FALSE")); but the bSerialIsValid is NOT set, which would be so much simpler than having to allocate a buffer on the stack, with the newly-added possibility of a buffer overrun! Of course, it would have been a lot easier if the author had used CString. But this is a pure-C example. And it is WRONG! joe > >Tom > >"jc" <jc(a)discussions.microsoft.com> wrote in message >news:97197843-154C-49A8-8298-C1BB2C560BD9(a)microsoft.com... >> Hello, >> >> I found MS's example on "How to Validate a Serial Number". >> However, the process seemed long and confusing. >> >> Does anybody know of a tool, that automates the process, >> of validating a programmer-defined serial number ? >> >> TIA, >> -jc Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: jc on 30 Apr 2010 15:47 Hi Tom, Thank you for taking the time to reply to my posting. I followed the link that you provided, and the web page stated, that there is a MS sample in VC++ 2008. A Visual C++ 2008 project in the file "MSISerialValidateSample.zip" located in the "Samples\Source Code" sub-folder of the MSI Factory installation folder. The compiled DLL that can be used for example purposes is called "MSISerialValidateSample.dll" and is located in the "Custom Actions" sub-folder of the MSI Factory installation folder. I searched everywhere for the file, and could not find it. Do I need to install an MSI SDK? TIA, -jc
|
Next
|
Last
Pages: 1 2 Prev: WM_TIMER remaining/elapsed time... Next: Rebuilding VS2010 MFC Static Libraries |