VisualCpp.org Collection of Visual C++ Stuffs

27Apr/090

You cannot change the state of a menu item from its command user-interface handler if the menu is attached to a dialog box in Visual C++?

Please refer KB Q242577  from Microsoft!... Why reinvent the whee l :-)

Filed under: General, MFC, Win32 No Comments
14Apr/091

Does anyone have an idea how I can detect if a file has been copied?

Recently on CP: Steve76063 ask above question. Full Text of question is below :-

Does anyone have an idea how I can detect if a file has been copied?

I'm trying to develop a simple (hopefully) protection scheme that'll allow me to distribute a license file to a customer, and our application will read the file to update their license.

What I don't want is for the client to be able to copy the license file and 'give' it to another of our customers and avoiding our licensing scheme.

Right now, our application reads the license file and then modifies it so that it's no good any more, so copying it after the fact wouldn't work...I'd like to prevent someone from copying the original un-altered file before it's used.

I've tried to use the GetFileTime() function to get the Creation, LastAccessed, and LastWrite times of the file, but these don't appear to change for a copy of the file.

Luc 648011 responds like this :-

I have seen lots of protection schemes, all free ones are (almost) worthless.
The best solutions are:

  1. no protection at all (no hassle for the user, no waste of time for the developer; yes you loose some customers who would not have paid for your product anyway);
  2. hardware-dependent protection
    2a. encode some characteristic (baseboard number, MAC address, disk number) in a license file; disadvantage: lots of hassle; customers don't like their software to stop functioning when they change some hardware, possibly for good reasons.
    2b. idem, with server access instead of license file; disadvantage: same plus needs internet every time.
    2c. deliver special hardware device (dongle). Costs ca 30$
    2d. link to the serial number of a USB stick (best of all these). Still the hassle.
  3. There is one: the physical sector number on disk. That is how some programs used to get protected on a floppy or CD. But then you could make binary copies of those disks (before first use).
    And good luck if you want your app, run by a non-admin, find out its sector number on modern Windows versions (Vista, 7).

In End, Steve suggests  solution, which he actually implementing:-

well, I may have found what I've been looking for...

Keep in mind, I'm not looking for a foolproof copy protection scheme--there's no such thing. We've used dongles before, but it gets cumbersome--especially when the client's computer already has 4 or 5 other dongles already attached!

I was just looking for a quick simple way to prevent unauthorized copying of my file.

I've found out that when I CreateFile() I can use the FILE_ATTRIBUTE_OFFLINE for the file and it's file icon is a light blue X, and it's Attribute is listed as O. If I copy the file to another location, it loses it's 'O' attribute! I'm can test for the attribute using the GetFileInformationByHandle() and it works just fine.

I'm just trying to deter casual copiers, not dedicated 'crackers', so this should be 'good enough'.

One caveat that I've just discovered is that the Offline attribute is only for NTFS drives, so that leaves out distributing my file via Floppy or CD...it'll have to be an NTFS formatted Flash Drive.

Filed under: General 1 Comment